Add ENABLE_DISCUSSION_EMAIL_DIGEST feature, to enable discussion emails digest by default for all users

This commit is contained in:
Alan Boudreault
2014-08-19 11:41:00 -04:00
committed by Matjaz Gregoric
parent c6aa4416c4
commit ac445d6eff
4 changed files with 55 additions and 12 deletions

View File

@@ -90,6 +90,31 @@ class UsernameCipher(object):
return UsernameCipher._remove_padding(decrypted)
def enable_notifications(user):
"""
Enable notifications for a user.
Currently only used for daily forum digests.
"""
UserPreference.objects.get_or_create(
user=user,
key=NOTIFICATION_PREF_KEY,
defaults={
"value": UsernameCipher.encrypt(user.username)
}
)
def disable_notifications(user):
"""
Disable notifications for a user.
Currently only used for daily forum digests.
"""
UserPreference.objects.filter(
user=user,
key=NOTIFICATION_PREF_KEY
).delete()
@require_POST
def ajax_enable(request):
"""
@@ -103,13 +128,7 @@ def ajax_enable(request):
if not request.user.is_authenticated():
raise PermissionDenied
UserPreference.objects.get_or_create(
user=request.user,
key=NOTIFICATION_PREF_KEY,
defaults={
"value": UsernameCipher.encrypt(request.user.username)
}
)
enable_notifications(request.user)
return HttpResponse(status=204)
@@ -125,10 +144,7 @@ def ajax_disable(request):
if not request.user.is_authenticated():
raise PermissionDenied
UserPreference.objects.filter(
user=request.user,
key=NOTIFICATION_PREF_KEY
).delete()
disable_notifications(request.user)
return HttpResponse(status=204)

View File

@@ -103,6 +103,13 @@ FEATURES = {
# this should remain off in production until digest notifications are online.
'ENABLE_DISCUSSION_HOME_PANEL': False,
# Set this to True if you want the discussion digest emails enabled automatically for new users.
# This will be set on all new account registrations.
# It is not recommended to enable this feature if ENABLE_DISCUSSION_HOME_PANEL is not enabled, since
# subscribers who receive digests in that case will only be able to unsubscribe via links embedded
# in their emails, and they will have no way to resubscribe.
'ENABLE_DISCUSSION_EMAIL_DIGEST': False,
'ENABLE_PSYCHOMETRICS': False, # real-time psychometrics (eg item response theory analysis in instructor dashboard)
'ENABLE_DJANGO_ADMIN_SITE': True, # set true to enable django's admin site, even on prod (e.g. for course ops)