Permalink
Browse files

raised error if multiple calls to Email.send() are called

  • Loading branch information...
1 parent 9324ff7 commit f2bca670cc5a4781b5f4964866b821d865ae8d17 @sherzberg sherzberg committed Aug 10, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 emailer/models.py
View
@@ -185,7 +185,11 @@ def _apply_merge_data(html, merge_data):
t = Template(html)
c = Context(merge_data)
return t.render(c)
-
+
+class IncorrectEmailStatus(Exception):
+ def __init__(self):
+ Exception.__init__(self)
+
class EmailManager(models.Manager):
def email_from_tracking(self, id):
@@ -257,6 +261,9 @@ def _build_message(self):
return msg
def send(self):
+ if self.status != Email.STATUS_PREPARED:
+ raise IncorrectEmailStatus("Email is not in status of prepared, something bad must have happened")
+
message = self._build_message()
try:

0 comments on commit f2bca67

Please sign in to comment.