Fix error sending notification to no email.
authorgibus
Mon, 18 Nov 2013 17:31:53 +0100
changeset 564 dc415eb33a3f
parent 563 163cf095f708
child 565 95a5c06c4008
Fix error sending notification to no email.
src/cm/notifications.py
--- a/src/cm/notifications.py	Wed Nov 06 19:07:25 2013 +0100
+++ b/src/cm/notifications.py	Mon Nov 18 17:31:53 2013 +0100
@@ -57,8 +57,9 @@
 
 def send_notification(activity, notification):
     email = notification.user.email if notification.user else notification.email
-    subject = _('Notification:') + " " + activity.printable_data(html=False, link=False)
-    message = render_to_string('email/activity_notification.txt',
+    if email:
+      subject = _('Notification:') + " " + activity.printable_data(html=False, link=False)
+      message = render_to_string('email/activity_notification.txt',
                                    { 
                                      'activity' : activity,
                                      'notification' : notification,
@@ -66,6 +67,6 @@
                                      'CONF' : ApplicationConfiguration,
                                       })
     
-    send_mail(subject, message, ApplicationConfiguration['email_from'], [email], fail_silently=True)
+      send_mail(subject, message, ApplicationConfiguration['email_from'], [email], fail_silently=True)
     
-    #logging.debug(u"Notification sent [%s] => %s" %(activity,notification.user) if notification.user else u"sending (email) %s => %s" %(activity,notification.email))
+      #logging.debug(u"Notification sent [%s] => %s" %(activity,notification.user) if notification.user else u"sending (email) %s => %s" %(activity,notification.email))