Email sent to a list of recipients, bug fixed list in a list
authorLoic Baron <loic.baron@lip6.fr>
Mon, 14 Apr 2014 12:30:22 +0000 (14:30 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 14 Apr 2014 12:30:22 +0000 (14:30 +0200)
portal/actions.py
portal/contactview.py
portal/joinview.py

index c612b09..8d351ab 100644 (file)
@@ -23,6 +23,7 @@ theme = ThemeView()
 def authority_get_pis(request, authority_hrn):
     query = Query.get('authority').filter_by('authority_hrn', '==', authority_hrn).select('pi_users')
     results = execute_admin_query(request, query)
+    print "authority_get_pis = %s" % results
     # NOTE: temporarily commented. Because results is giving empty list. 
     # Needs more debugging
     #if not results:
@@ -33,6 +34,8 @@ def authority_get_pis(request, authority_hrn):
 
 def authority_get_pi_emails(request, authority_hrn):
     pi_users = authority_get_pis(request,authority_hrn)
+    print "pi_users = %s" % pi_users
+
     if any(d['pi_users'] == None for d in pi_users):
         theme.template_name = 'email_default_recipients.txt' 
         default_email = render_to_string(theme.template, request)
@@ -402,7 +405,7 @@ def create_pending_slice(wsgi_request, request, email):
     try:
         # Send an email: the recipients are the PI of the authority
         recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
-    
+
         theme.template_name = 'slice_request_email.txt' 
         text_content = render_to_string(theme.template, request)
     
@@ -414,8 +417,7 @@ def create_pending_slice(wsgi_request, request, email):
         subject = subject.replace('\n', '')
     
         sender = email
-        msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
-        print msg
+        msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
         msg.attach_alternative(html_content, "text/html")
         msg.send()
     except Exception, e:
@@ -593,8 +595,10 @@ def create_pending_user(wsgi_request, request, user_detail):
         sender =  render_to_string(theme.template, request)
         sender = sender.replace('\n', '')
     
-        msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+        msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
         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"
+        import traceback
+        traceback.print_exc()
index 95fb44e..44c151c 100644 (file)
@@ -50,7 +50,7 @@ class ContactView (FreeAccessView, ThemeView):
                 else:
                     sender = email
         
-                msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+                msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
                 msg.attach_alternative(html_content, "text/html")
                 msg.send()
             except Exception, e:
index a2b8b7d..c128db3 100644 (file)
@@ -205,7 +205,7 @@ class JoinView (FreeAccessView, ThemeView):
                     sender =  render_to_string(theme.template, ctx)
                     sender = sender.replace('\n', '')
             
-                    msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+                    msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
                     msg.attach_alternative(html_content, "text/html")
                     msg.send()