Add ENABLE_DISCUSSION_EMAIL_DIGEST feature, to enable discussion emails digest by default for all users
This commit is contained in:
committed by
Matjaz Gregoric
parent
c6aa4416c4
commit
ac445d6eff
@@ -14,6 +14,7 @@ import mock
|
||||
|
||||
from openedx.core.djangoapps.user_api.models import UserPreference
|
||||
from lang_pref import LANGUAGE_KEY
|
||||
from notification_prefs import NOTIFICATION_PREF_KEY
|
||||
|
||||
from edxmako.tests import mako_middleware_process_request
|
||||
from external_auth.models import ExternalAuthMap
|
||||
@@ -50,8 +51,8 @@ class TestCreateAccount(TestCase):
|
||||
@ddt.data("en", "eo")
|
||||
def test_header_lang_pref_saved(self, lang):
|
||||
response = self.client.post(self.url, self.params, HTTP_ACCEPT_LANGUAGE=lang)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
user = User.objects.get(username=self.username)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(UserPreference.get_preference(user, LANGUAGE_KEY), lang)
|
||||
|
||||
def base_extauth_bypass_sending_activation_email(self, bypass_activation_email_for_extauth_setting):
|
||||
@@ -98,6 +99,18 @@ class TestCreateAccount(TestCase):
|
||||
"""
|
||||
self.base_extauth_bypass_sending_activation_email(False)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_discussions_email_digest_pref(self, digest_enabled):
|
||||
with mock.patch.dict("student.models.settings.FEATURES", {"ENABLE_DISCUSSION_EMAIL_DIGEST": digest_enabled}):
|
||||
response = self.client.post(self.url, self.params)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
user = User.objects.get(username=self.username)
|
||||
preference = UserPreference.get_preference(user, NOTIFICATION_PREF_KEY)
|
||||
if digest_enabled:
|
||||
self.assertIsNotNone(preference)
|
||||
else:
|
||||
self.assertIsNone(preference)
|
||||
|
||||
|
||||
@mock.patch.dict("student.models.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
|
||||
@mock.patch("lms.lib.comment_client.User.base_url", TEST_CS_URL)
|
||||
|
||||
@@ -86,6 +86,7 @@ from bulk_email.models import Optout, CourseAuthorization
|
||||
import shoppingcart
|
||||
from openedx.core.djangoapps.user_api.models import UserPreference
|
||||
from lang_pref import LANGUAGE_KEY
|
||||
from notification_prefs.views import enable_notifications
|
||||
|
||||
import track.views
|
||||
|
||||
@@ -1589,6 +1590,12 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
|
||||
|
||||
(user, profile, registration) = ret
|
||||
|
||||
if settings.FEATURES.get('ENABLE_DISCUSSION_EMAIL_DIGEST'):
|
||||
try:
|
||||
enable_notifications(user)
|
||||
except Exception:
|
||||
log.exception("Enable discussion notifications failed for user {id}.".format(id=user.id))
|
||||
|
||||
dog_stats_api.increment("common.student.account_created")
|
||||
|
||||
email = post_vars['email']
|
||||
|
||||
Reference in New Issue
Block a user