diff --git a/openedx/core/djangoapps/notifications/email/tests/test_tasks.py b/openedx/core/djangoapps/notifications/email/tests/test_tasks.py index 78dbc957833..5c88ef3edb1 100644 --- a/openedx/core/djangoapps/notifications/email/tests/test_tasks.py +++ b/openedx/core/djangoapps/notifications/email/tests/test_tasks.py @@ -153,6 +153,7 @@ def test_digest_should_contain_email_enabled_notifications(self, email_value, mo assert mock_func.called is email_value +@ddt.ddt class TestPreferences(ModuleStoreTestCase): """ Tests preferences @@ -176,11 +177,27 @@ def test_email_send_for_digest_preference(self, mock_func): config = self.preference.notification_preference_config types = config['discussion']['notification_types'] types['new_discussion_post']['email_cadence'] = EmailCadence.DAILY + types['new_discussion_post']['email'] = True self.preference.save() with override_waffle_flag(ENABLE_EMAIL_NOTIFICATIONS, True): send_digest_email_to_user(self.user, EmailCadence.DAILY) assert mock_func.called + @ddt.data(True, False) + @patch('edx_ace.ace.send') + def test_email_send_for_email_preference_value(self, pref_value, mock_func): + """ + Tests email is sent iff preference value is True + """ + config = self.preference.notification_preference_config + types = config['discussion']['notification_types'] + types['new_discussion_post']['email_cadence'] = EmailCadence.DAILY + types['new_discussion_post']['email'] = pref_value + self.preference.save() + with override_waffle_flag(ENABLE_EMAIL_NOTIFICATIONS, True): + send_digest_email_to_user(self.user, EmailCadence.DAILY) + assert mock_func.called is pref_value + @patch('edx_ace.ace.send') def test_email_not_send_if_different_digest_preference(self, mock_func): """ diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index 9538620b06c..07b1bf1330a 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -224,7 +224,7 @@ def get_enabled_notification_types_for_cadence(preferences, cadence_type=EmailCa config = preference.notification_preference_config for app_data in config.values(): for notification_type, type_dict in app_data['notification_types'].items(): - if type_dict['email_cadence'] == cadence_type: + if (type_dict['email_cadence'] == cadence_type) and type_dict['email']: value.append(notification_type) if 'core' in value: value.remove('core') diff --git a/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html b/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html index f7cb37fcfe7..1da86f48f0b 100644 --- a/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html +++ b/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html @@ -39,7 +39,7 @@

{{ notification.course_name }} - · + {{ "·"|safe }} {{ notification.time_ago }} diff --git a/openedx/core/djangoapps/notifications/templates/notifications/edx_ace/email_digest/email/body.html b/openedx/core/djangoapps/notifications/templates/notifications/edx_ace/email_digest/email/body.html index e45fd8029e2..76658a04366 100644 --- a/openedx/core/djangoapps/notifications/templates/notifications/edx_ace/email_digest/email/body.html +++ b/openedx/core/djangoapps/notifications/templates/notifications/edx_ace/email_digest/email/body.html @@ -1,4 +1,4 @@ -
+
@@ -18,5 +18,4 @@
-