From: Loic Baron <loic.baron@lip6.fr>
Date: Mon, 14 Apr 2014 12:30:22 +0000 (+0200)
Subject: Email sent to a list of recipients, bug fixed list in a list
X-Git-Tag: myslice-1.1~144
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6f6612123b45e1049c03c5f0e58ea780a7bed7ef;p=unfold.git

Email sent to a list of recipients, bug fixed list in a list
---

diff --git a/portal/actions.py b/portal/actions.py
index c612b096..8d351ab9 100644
--- a/portal/actions.py
+++ b/portal/actions.py
@@ -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()
diff --git a/portal/contactview.py b/portal/contactview.py
index 95fb44e8..44c151c4 100644
--- a/portal/contactview.py
+++ b/portal/contactview.py
@@ -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:
diff --git a/portal/joinview.py b/portal/joinview.py
index a2b8b7d9..c128db3b 100644
--- a/portal/joinview.py
+++ b/portal/joinview.py
@@ -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()