]> git.openstreetmap.org Git - osqa.git/commitdiff
OSQA-706, send daily digest only to users that are active and have validated their...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 7 Jul 2011 01:07:57 +0000 (01:07 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 7 Jul 2011 01:07:57 +0000 (01:07 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1108 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/management/commands/send_email_alerts.py
forum/settings/email.py

index 80159e7988554b2ccbaba2188670836816f4333d..06cad53e1903d4956406d99d535a8d6967fbb96a 100644 (file)
@@ -91,7 +91,17 @@ class Command(NoArgsCommand):
 
         EMAIL_DIGEST_FLAG.set_value(digest_control)
 
-        users = User.objects.filter(subscription_settings__enable_notifications=True, subscription_settings__send_digest=True)
+        users = User.objects.filter(subscription_settings__enable_notifications=True,
+                                    subscription_settings__send_digest=True)
+
+        # Send digest only to active users
+        if settings.SEND_DIGEST_ONLY_TO_ACTIVE_USERS:
+            users = users.filter(is_active=True)
+
+        # Send digest only to users with validated emails
+        if settings.SEND_DIGEST_ONLY_TO_VALIDATED_USERS:
+            users = users.filter(email_isvalid=True)
+
         new_members = User.objects.filter(is_active=True, date_joined__gt=from_date).annotate(n_actions=models.Count('actions')).order_by('-n_actions')
 
         new_member_count = new_members.count()
index e934d30a4ac9b52e0b2e37ea3deff06f94d524cd..583ab0d42f24d23fccbba88c3b216cbe56d7997e 100644 (file)
@@ -68,6 +68,14 @@ label = _("Email Link Style"),
 help_text = _("A valid css string to be used to style email links (the A tag)."),\r
 required=False))\r
 \r
+SEND_DIGEST_ONLY_TO_ACTIVE_USERS = Setting('SEND_DIGEST_ONLY_TO_ACTIVE_USERS', True, EMAIL_SET, dict(\r
+label = _("Send digest only to active users"),\r
+help_text = _("If checked the daily digest won't be sent to users that have been suspended."),\r
+required=False))\r
 \r
+SEND_DIGEST_ONLY_TO_VALIDATED_USERS = Setting('SEND_DIGEST_ONLY_TO_VALIDATED_USERS', True, EMAIL_SET, dict(\r
+label = _("Send digest only to validated users"),\r
+help_text = _("If checked the daily digest won't be sent to users that haven't validated their emails."),\r
+required=False))\r
 \r
 EMAIL_DIGEST_FLAG = Setting('EMAIL_DIGEST_FLAG', None)\r