From b38c02cafcb7d3bc655c5a203665dcd3bc5ecef4 Mon Sep 17 00:00:00 2001 From: Rezende Date: Thu, 24 Jul 2014 19:34:48 -0300 Subject: [PATCH] All users and slices are created in the topdomain authority (fibre) Modification in the email sender --- portal/actions.py | 17 +++++++++++++++-- portal/managementtabrequests.py | 2 +- .../fibre/fibre_email_default_sender.txt | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 portal/templates/fibre/fibre_email_default_sender.txt diff --git a/portal/actions.py b/portal/actions.py index b399ca29..42d0667c 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -115,6 +115,10 @@ def manifold_add_user(wsgi_request, request): ? """ + + authority_hrn = request['authority_hrn'] + request['authority_hrn'] = authority_hrn.split(".")[0] + USER_CONFIG = '{"firstname": "%(first_name)s", "lastname": "%(last_name)s", "authority": "%(authority_hrn)s"}' user_params = { @@ -124,6 +128,8 @@ def manifold_add_user(wsgi_request, request): 'status' : 1, } + request['authority_hrn'] = authority_hrn + query = Query.create('local:user').set(user_params).select('email') results = execute_admin_query(request, query) if not results: @@ -435,7 +441,11 @@ def create_pending_slice(wsgi_request, request, email): subject = render_to_string(theme.template, request) subject = subject.replace('\n', '') - sender = email + theme.template_name = 'email_default_sender.txt' + sender = render_to_string(theme.template, request) + sender = sender.replace('\n', '') + + #sender = email msg = EmailMultiAlternatives(subject, text_content, sender, recipients) msg.attach_alternative(html_content, "text/html") msg.send() @@ -781,7 +791,10 @@ def create_pending_user(wsgi_request, request, user_detail): try: # Send an email: the recipients are the PI of the authority # If No PI is defined for this Authority, send to a default email (different for each theme) - recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn']) + + split_authority_hrn = request['authority_hrn'].split(".")[0] + + recipients = authority_get_pi_emails(wsgi_request, split_authority_hrn) theme.template_name = 'user_request_email.html' html_content = render_to_string(theme.template, request) diff --git a/portal/managementtabrequests.py b/portal/managementtabrequests.py index 6e37f1d4..85985a06 100644 --- a/portal/managementtabrequests.py +++ b/portal/managementtabrequests.py @@ -33,7 +33,7 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): # The user need to be logged in if (self.request.user): - user_query = Query().get('local:user').filter_by('email', '==', self.request.user.email).select('user_id') + user_query = Query().get('local:user').filter_by('email', '==', self.request.user.username).select('user_id') user, = execute_query(self.request, user_query) user_id = user['user_id'] diff --git a/portal/templates/fibre/fibre_email_default_sender.txt b/portal/templates/fibre/fibre_email_default_sender.txt new file mode 100644 index 00000000..32008b99 --- /dev/null +++ b/portal/templates/fibre/fibre_email_default_sender.txt @@ -0,0 +1 @@ +support@fibre.org.br -- 2.45.2