Skip to content

Commit

Permalink
Notify accounts depending on state
Browse files Browse the repository at this point in the history
- Only accounts that are 'active' or 'disabled' should receive emails notifying
  them that they have new messages.
- Fixes chb#39
  • Loading branch information
Travers Franckle committed Oct 8, 2012
1 parent b36961b commit c22cbfd
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions indivo/models/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,19 @@ def send_secret(self):
["%s <%s>" % (self.full_name or self.contact_email, self.contact_email)])

def notify_account_of_new_message(self):
subject = utils.render_template_raw('email/new_message/subject', {'account': self}, type='txt').strip()
body = utils.render_template_raw('email/new_message/body',
{'account': self,
'full_name': self.full_name or self.contact_email,
'url_prefix': settings.UI_SERVER_URL,
'email_support_name': settings.EMAIL_SUPPORT_NAME,
'email_support_address': settings.EMAIL_SUPPORT_ADDRESS },
type='txt')
utils.send_mail(subject, body,
"%s <%s>" % (settings.EMAIL_SUPPORT_NAME, settings.EMAIL_SUPPORT_ADDRESS),
["%s <%s>" % (self.full_name or self.contact_email, self.contact_email)])
# only notify accounts that have a state of active or disabled
if self.state == ACTIVE or self.state == DISABLED:
subject = utils.render_template_raw('email/new_message/subject', {'account': self}, type='txt').strip()
body = utils.render_template_raw('email/new_message/body',
{'account': self,
'full_name': self.full_name or self.contact_email,
'url_prefix': settings.UI_SERVER_URL,
'email_support_name': settings.EMAIL_SUPPORT_NAME,
'email_support_address': settings.EMAIL_SUPPORT_ADDRESS },
type='txt')
utils.send_mail(subject, body,
"%s <%s>" % (settings.EMAIL_SUPPORT_NAME, settings.EMAIL_SUPPORT_ADDRESS),
["%s <%s>" % (self.full_name or self.contact_email, self.contact_email)])

def send_welcome_email(self):
subject = utils.render_template_raw('email/welcome/subject', {'account': self}, type='txt').strip()
Expand Down

0 comments on commit c22cbfd

Please sign in to comment.