authority req rejected email added
authorYasin <mohammed-yasin.rahman@lip6.fr>
Mon, 1 Sep 2014 13:53:58 +0000 (15:53 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Mon, 1 Sep 2014 13:53:58 +0000 (15:53 +0200)
portal/actions.py
portal/templates/authority_request_denied.html [new file with mode: 0644]
portal/templates/authority_request_denied.txt [new file with mode: 0644]
portal/templates/slice_request_denied.html
portal/templates/slice_request_denied.txt

index 0845619..b272e2d 100644 (file)
@@ -406,6 +406,10 @@ def reject_action(request, **kwargs):
 
 def portal_reject_request(wsgi_request, request_ids):
     status = {}
+    # get the domain url    
+    current_site = Site.objects.get_current()
+    current_site = current_site.domain
+
 
     if not isinstance(request_ids, list):
         request_ids = [request_ids]
@@ -429,10 +433,6 @@ def portal_reject_request(wsgi_request, request_ids):
                     first_name = user.first_name
                     last_name = user.last_name
 
-                # get the domain url
-                current_site = Site.objects.get_current()
-                current_site = current_site.domain
-
                 ctx = {
                     'first_name'    : first_name, 
                     'last_name'     : last_name, 
@@ -447,7 +447,7 @@ def portal_reject_request(wsgi_request, request_ids):
                     sender =  render_to_string(theme.template, ctx)
                     sender = sender.replace('\n', '')
                                
-                    subject = 'User validation denied.'
+                    subject = 'User request denied.'
 
                     msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
                     msg.attach_alternative(html_content, "text/html")
@@ -487,36 +487,74 @@ def portal_reject_request(wsgi_request, request_ids):
 
             # getting user email based on id 
             ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
-            for user in PendingUser.objects.raw('SELECT * FROM portal_pendingslice WHERE id = %s', [request['id']]):
-                user_email= user.type_of_nodes # XXX type_of_nodes field contains the email [shd be renamed]
-
-                # get the domain url
-                current_site = Site.objects.get_current()
-                current_site = current_site.domain
-
-                ctx = {
-                    'portal_url'    : current_site,
-                    }
-                try:
-                    theme.template_name = 'slice_request_denied.txt'
-                    text_content = render_to_string(theme.template, ctx)
-                    theme.template_name = 'slice_request_denied.html'
-                    html_content = render_to_string(theme.template, ctx)
-                    theme.template_name = 'email_default_sender.txt'
-                    sender =  render_to_string(theme.template, ctx)
-                    sender = sender.replace('\n', '')
+            for user in PendingSlice.objects.raw('SELECT * FROM portal_pendingslice WHERE id = %s', [request['id']]):
+                user_email= user.type_of_nodes # XXX type_of_nodes field contains the email [shd be renamed in DB]
+                slice_name = user.slice_name
+                purpose = user.purpose
+                url = user.number_of_nodes
+
+            ctx = {
+                'slice_name': slice_name,
+                'purpose': purpose,
+                'url': url,
+                'portal_url': current_site,
+                }
+            try:
+                theme.template_name = 'slice_request_denied.txt'
+                text_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'slice_request_denied.html'
+                html_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'email_default_sender.txt'
+                sender =  render_to_string(theme.template, ctx)
+                sender = sender.replace('\n', '')
                                
-                    subject = 'Slice request denied.'
+                subject = 'Slice request denied.'
 
-                    msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
-                    msg.attach_alternative(html_content, "text/html")
-                    msg.send()
-                except Exception, e:
-                    print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+                msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+                msg.attach_alternative(html_content, "text/html")
+                msg.send()
+            except Exception, e:
+                print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
                       
             PendingSlice.objects.get(id=request['id']).delete()
+
         elif request['type'] == 'authority':
-            request_status['SFA authority'] = {'status': True }           
+            request_status['SFA authority'] = {'status': True }
+            
+            # getting user email based on id 
+            ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
+            for user in PendingAuthority.objects.raw('SELECT * FROM portal_pendingauthority WHERE id = %s', [request['id']]):
+                user_email= user.address_line1 # XXX address_line1 field contains the email [shd be renamed in DB]
+                site_name = user.site_name
+                city = user.address_city
+                country = user.address_country
+                short_name = user.site_abbreviated_name
+                url = user.site_url
+
+            ctx = { 
+                'site_name': site_name,
+                'short_name': short_name,
+                'url': url,
+                'city': city,
+                'country': country,                          
+                'portal_url'    : current_site,
+                }
+                
+            try:
+                theme.template_name = 'authority_request_denied.txt'
+                text_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'authority_request_denied.html'
+                html_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'email_default_sender.txt'
+                sender =  render_to_string(theme.template, ctx)
+                sender = sender.replace('\n', '')
+                subject = 'Authority request denied.'
+                msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+                msg.attach_alternative(html_content, "text/html")
+                msg.send()
+            except Exception, e:
+                print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
             PendingAuthority.objects.get(id=request['id']).delete()
 
         status['%s__%s' % (request['type'], request['id'])] = request_status
diff --git a/portal/templates/authority_request_denied.html b/portal/templates/authority_request_denied.html
new file mode 100644 (file)
index 0000000..a028170
--- /dev/null
@@ -0,0 +1,20 @@
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested an addition of the following authority in the OneLab portal ({{portal_url}}):</p> 
+<p></p>
+<b>Name of organization:</b> {{site_name}}<br>
+<b>Short name:</b> {{short_name}}<br>
+<b>Url:</b> {{url}}<br>
+<b>City:</b> {{city}}<br>
+<b>Country:</b> {{country}}<br>
+<p></p>
+</p>After verifying your request, we regret to inform you that, we are unable to validate your request.</p>
+<p>For any queries, contact us by replying to this email.</p>
+<br>
+<p>On behalf of the entire team, I wish you all the best.</p>
+<br>
+<p>Yours sincerely,</p>
+<br>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
diff --git a/portal/templates/authority_request_denied.txt b/portal/templates/authority_request_denied.txt
new file mode 100644 (file)
index 0000000..7708b3f
--- /dev/null
@@ -0,0 +1,21 @@
+Dear OneLab user,
+
+You have recently requested an addition of the following authority in the OneLab portal ({{portal_url}}): 
+
+Name of organization: {{site_name}}
+Short name: {{short_name}}
+Url: {{url}}
+City: {{city}}
+Country: {{country}}
+
+
+After verifying your request, we regret to inform you that, we are unable to validate your request.
+For any queries, contact us by replying to this email.
+
+On behalf of the entire team, I wish you all the best.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
index d9ebaad..2405490 100644 (file)
@@ -2,12 +2,18 @@
 <br>
 <p>Dear OneLab user,</p>
 <p></p>
-<p>You have recently requested a slice in the OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.</p>
-<p></p>
+<p>You have recently requested the following slice in the OneLab portal({{portal_url}}):</p> 
+<br>
+<b>Slice name   :</b> {{slice_name}}<br>
+<b>URL          :</b> {{url}}<br>
+<b>Purpose      :</b> {{purpose}}<br>
+<br>
+<p>We regret to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.</p>
+<br>
 <p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
-<p></p>
+<br>
 <p>Yours sincerely,</p>
-<p></p>
+<br>
 <p>Timur Friedman</p>
 <p>Executive Director</p>
 
index c2587df..7dcbee3 100644 (file)
@@ -1,6 +1,12 @@
 Dear OneLab user,
 
-You have recently requested a slice in the OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.
+You have recently requested the following slice in the OneLab portal({{portal_url}}):
+
+Slice name   : {{slice_name}}
+URL          : {{url}}
+Purpose      : {{purpose}}
+We regret to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.
 
 On behalf of the entire team, I wish you a fruitful user experience on OneLab..