Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit f2bca670cc5a4781b5f4964866b821d865ae8d17 1 parent 9324ff7
Spencer Herzberg sherzberg authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 emailer/models.py
9 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:
Please sign in to comment.
Something went wrong with that request. Please try again.