From 7822d49431677ee64c813e841cd8c82dc7bac4b6 Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Thu, 19 Jun 2014 17:37:08 +0100 Subject: [PATCH] Implement checking of user notification preferences before send_notification() --- wagtail/wagtailadmin/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wagtail/wagtailadmin/tasks.py b/wagtail/wagtailadmin/tasks.py index 59779d36b..567a91f85 100644 --- a/wagtail/wagtailadmin/tasks.py +++ b/wagtail/wagtailadmin/tasks.py @@ -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