Added mailer check
authorThierry Florac <thierry.florac@onf.fr>
Thu, 08 Jun 2017 11:34:40 +0200
changeset 83 cedc7584a81f
parent 82 4e3b341baaec
child 84 7214a95eaa9b
Added mailer check
src/pyams_content/shared/common/review.py
--- a/src/pyams_content/shared/common/review.py	Tue Jun 06 17:13:27 2017 +0200
+++ b/src/pyams_content/shared/common/review.py	Thu Jun 08 11:34:40 2017 +0200
@@ -139,7 +139,10 @@
         if sender_mail_info is not None:
             for sender_name, sender_address in sender_mail_info.get_addresses():
                 break
-        mailer = query_utility(IMailer, name=settings.mailer)
+        if settings.enable_notifications:
+            mailer = query_utility(IMailer, name=settings.mailer)
+        else:
+            mailer = None
         # create message
         message_body = self.review_template(request=request,
                                             context=self.context,
@@ -151,7 +154,9 @@
         notifications = 0
         readers = roles.readers
         for reviewer in reviewers:
-            if settings.enable_notifications and (notify_all or (reviewer not in readers)):
+            if settings.enable_notifications and \
+                    (mailer is not None) and \
+                    (notify_all or (reviewer not in readers)):
                 principal = security.get_principal(reviewer, info=False)
                 if not isinstance(principal, MissingPrincipal):
                     mail_info = IPrincipalMailInfo(principal, None)