slice req validate email: updated template and text
authorYasin <mohammed-yasin.rahman@lip6.fr>
Fri, 29 Aug 2014 13:23:16 +0000 (15:23 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Fri, 29 Aug 2014 13:23:16 +0000 (15:23 +0200)
portal/actions.py
portal/templates/slice_request_validated.html [new file with mode: 0644]
portal/templates/slice_request_validated.txt [new file with mode: 0644]

index d4bc8ea..d95a78e 100644 (file)
@@ -548,9 +548,24 @@ def create_slice(wsgi_request, request):
         raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
     else:
         clear_user_creds(wsgi_request,user_email)
-        subject = 'Slice created'
-        msg = 'A manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.'
-        send_mail(subject, msg, 'support@onelab.eu',[user_email], fail_silently=False)
+
+        try:
+            theme.template_name = 'slice_request_validated.txt'
+            text_content = render_to_string(theme.template, request)
+            theme.template_name = 'slice_request_validated.html'
+            html_content = render_to_string(theme.template, request)
+        
+            theme.template_name = 'email_default_sender.txt'
+            sender =  render_to_string(theme.template, request)
+            sender = sender.replace('\n', '')
+
+            subject = 'Slice request validated'
+
+            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"
        
     return results
 
diff --git a/portal/templates/slice_request_validated.html b/portal/templates/slice_request_validated.html
new file mode 100644 (file)
index 0000000..9c18227
--- /dev/null
@@ -0,0 +1,20 @@
+<img src="{{ STATIC_URL }}img/onelab.png">
+<br>
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested a slice in the OneLab portal.</p>
+<br>
+<b>Slice name   :</b> {{slice_name}}<br>
+<b>URL          :</b> {{number_of_nodes}}<br>
+<b>Purpose      :</b> {{purpose}}<br>
+<p></p>
+<p>We are glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
+<p></p>
+<p>Yours sincerely,</p>
+
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
+
diff --git a/portal/templates/slice_request_validated.txt b/portal/templates/slice_request_validated.txt
new file mode 100644 (file)
index 0000000..f0cd3c5
--- /dev/null
@@ -0,0 +1,18 @@
+Dear OneLab user,
+
+You have recently requested a slice in the OneLab portal.
+
+Slice name      : {{slice_name}}
+URL             : {{number_of_nodes}}
+Purpose         : {{purpose}}
+
+We are glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
+