[damned-lies] Test that coordinator exists before sending it a message



commit 71f68360758e438d066417483457312f74c088c1
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon Dec 7 20:57:00 2009 +0100

    Test that coordinator exists before sending it a message

 teams/models.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/teams/models.py b/teams/models.py
index 0dcd0fc..1b9e43d 100644
--- a/teams/models.py
+++ b/teams/models.py
@@ -188,6 +188,9 @@ class Team(models.Model):
     def send_mail_to_coordinator(self, subject, message, messagekw={}):
         """ Send a message to the coordinator, in her language if available
             and if subject and message are lazy strings """
+        coordinator = self.get_coordinator()
+        if not coordinator or not coordinator.email:
+            return
         prev_lang = translation.get_language()
         translation.activate(self.language_set.all()[0].locale)
 
@@ -197,7 +200,7 @@ class Team(models.Model):
             subject,
             message,
             settings.DEFAULT_FROM_EMAIL,
-            [self.get_coordinator().email]
+            [coordinator.email]
         )
         translation.activate(prev_lang)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]