Implement checking of user notification preferences before send_notification()

This commit is contained in:
Nick Smith 2014-06-19 17:37:08 +01:00
parent 6dcb489d6b
commit 7822d49431

View file

@ -53,7 +53,7 @@ def send_notification(page_revision_id, notification, excluded_user_id):
if notification == 'submitted':
# Get list of publishers
recipients = users_with_page_permission(revision.page, 'publish')
elif notification == 'approved' or notification == 'rejected':
elif notification in ['rejected', 'approved']:
# Get submitter
recipients = [revision.user]
else:
@ -62,7 +62,7 @@ def send_notification(page_revision_id, notification, excluded_user_id):
# Get list of email addresses
email_addresses = [
recipient.email for recipient in recipients
if recipient.email and recipient.id != excluded_user_id
if recipient.email and recipient.id != excluded_user_id and getattr(recipient.get_profile(), notification + '_notifications')
]
# Return if there are no email addresses