Skip to content

Commit

Permalink
allow disabling of email saving
Browse files Browse the repository at this point in the history
  • Loading branch information
jscott1989 committed Jun 30, 2016
1 parent 94aab7e commit 0a7db26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/emails/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def status(self):
return "Active"
return "Pending"

def send(self, user):
def send(self, user, save=True):
"""Send the email to a user, if they haven't already received it."""
sent_email = SentEmail(email=self, email_address=user.email)
if isinstance(user, EmailUser):
Expand All @@ -59,12 +59,13 @@ def send(self, user):
content=render_email(self.content, user, self.event)
).send()

sent_email.save()
if save:
sent_email.save()

def send_all(self):
def send_all(self, save=True):
"""Send the email to all eligible users."""
for user in filtering.query(self.to):
self.send(user)
self.send(user, save)

def save(self):
"""Automatically send emails if required."""
Expand Down

0 comments on commit 0a7db26

Please sign in to comment.