From 9bd692413ad207877e87fd3a796698a308275f1e Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Wed, 7 Aug 2024 14:55:02 +0500 Subject: [PATCH] fix: make course update email pref false (#35224) fix: updated unit tests fix: updated unit tests --- cms/djangoapps/contentstore/utils.py | 2 +- openedx/core/djangoapps/notifications/base_notification.py | 6 +++--- .../core/djangoapps/notifications/email/tests/test_utils.py | 4 ++-- openedx/core/djangoapps/notifications/models.py | 2 +- openedx/core/djangoapps/notifications/tests/test_tasks.py | 2 +- openedx/core/djangoapps/notifications/tests/test_views.py | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index b268bd6fcb5d..631ceeb270b6 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -2255,7 +2255,7 @@ def send_course_update_notification(course_key, content, user): "course_update_content": text_content if len(text_content.strip()) < 10 else "Click here to view", **extra_context, }, - notification_type="course_update", + notification_type="course_updates", content_url=f"{settings.LMS_ROOT_URL}/courses/{str(course_key)}/course/updates", app_name="updates", audience_filters={}, diff --git a/openedx/core/djangoapps/notifications/base_notification.py b/openedx/core/djangoapps/notifications/base_notification.py index 302d77328765..2813002fdb77 100644 --- a/openedx/core/djangoapps/notifications/base_notification.py +++ b/openedx/core/djangoapps/notifications/base_notification.py @@ -169,13 +169,13 @@ 'email_template': '', 'filters': [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE] }, - 'course_update': { + 'course_updates': { 'notification_app': 'updates', - 'name': 'course_update', + 'name': 'course_updates', 'is_core': False, 'info': '', 'web': True, - 'email': True, + 'email': False, 'push': True, 'email_cadence': EmailCadence.DAILY, 'non_editable': [], diff --git a/openedx/core/djangoapps/notifications/email/tests/test_utils.py b/openedx/core/djangoapps/notifications/email/tests/test_utils.py index 8d72ffd748b5..6e79c497a4fe 100644 --- a/openedx/core/djangoapps/notifications/email/tests/test_utils.py +++ b/openedx/core/djangoapps/notifications/email/tests/test_utils.py @@ -70,7 +70,7 @@ def test_create_app_notifications_dict(self): """ Notification.objects.all().delete() create_notification(self.user, self.course.id, app_name='discussion', notification_type='new_comment') - create_notification(self.user, self.course.id, app_name='updates', notification_type='course_update') + create_notification(self.user, self.course.id, app_name='updates', notification_type='course_updates') app_dict = create_app_notifications_dict(Notification.objects.all()) assert len(app_dict.keys()) == 2 for key in ['discussion', 'updates']: @@ -130,7 +130,7 @@ def test_email_digest_context(self, digest_frequency): discussion_notification = create_notification(self.user, self.course.id, app_name='discussion', notification_type='new_comment') update_notification = create_notification(self.user, self.course.id, app_name='updates', - notification_type='course_update') + notification_type='course_updates') app_dict = create_app_notifications_dict(Notification.objects.all()) end_date = datetime.datetime(2024, 3, 24, 12, 0) params = { diff --git a/openedx/core/djangoapps/notifications/models.py b/openedx/core/djangoapps/notifications/models.py index 8bf19edce56e..e1bdf94acc33 100644 --- a/openedx/core/djangoapps/notifications/models.py +++ b/openedx/core/djangoapps/notifications/models.py @@ -23,7 +23,7 @@ ADDITIONAL_NOTIFICATION_CHANNEL_SETTINGS = ['email_cadence'] # Update this version when there is a change to any course specific notification type or app. -COURSE_NOTIFICATION_CONFIG_VERSION = 10 +COURSE_NOTIFICATION_CONFIG_VERSION = 11 def get_course_notification_preference_config(): diff --git a/openedx/core/djangoapps/notifications/tests/test_tasks.py b/openedx/core/djangoapps/notifications/tests/test_tasks.py index 5058c0f492c3..706ae2989842 100644 --- a/openedx/core/djangoapps/notifications/tests/test_tasks.py +++ b/openedx/core/djangoapps/notifications/tests/test_tasks.py @@ -390,7 +390,7 @@ def test_app_name_param(self): """ assert not Notification.objects.all() create_notification(self.user, self.course_1.id, app_name='discussion', notification_type='new_comment') - create_notification(self.user, self.course_1.id, app_name='updates', notification_type='course_update') + create_notification(self.user, self.course_1.id, app_name='updates', notification_type='course_updates') delete_notifications({'app_name': 'discussion'}) assert not Notification.objects.filter(app_name='discussion') assert Notification.objects.filter(app_name='updates') diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index 389c9e7e06c9..d2968749efab 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -275,9 +275,9 @@ def _expected_api_response(self, course=None): 'enabled': True, 'core_notification_types': [], 'notification_types': { - 'course_update': { + 'course_updates': { 'web': True, - 'email': True, + 'email': False, 'push': True, 'email_cadence': 'Daily', 'info': ''