From f90f1af117433b9a401fabbfa9a836e357682dde Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:02:52 +0500 Subject: [PATCH] fix: added new_comment and new_response to core notification (#32894) --- .../notifications/base_notification.py | 12 +++--------- .../core/djangoapps/notifications/models.py | 2 +- .../notifications/tests/test_views.py | 19 ++----------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/openedx/core/djangoapps/notifications/base_notification.py b/openedx/core/djangoapps/notifications/base_notification.py index 692f46c3a289..0e97a2f32403 100644 --- a/openedx/core/djangoapps/notifications/base_notification.py +++ b/openedx/core/djangoapps/notifications/base_notification.py @@ -25,10 +25,7 @@ 'new_comment': { 'notification_app': 'discussion', 'name': 'new_comment', - 'is_core': False, - 'web': True, - 'email': True, - 'push': True, + 'is_core': True, 'info': 'Comment on post', 'non_editable': ['web', 'email'], 'content_template': _('<{p}><{strong}>{replier_name} commented on <{strong}>{author_name}\'s' @@ -43,10 +40,7 @@ 'new_response': { 'notification_app': 'discussion', 'name': 'new_response', - 'is_core': False, - 'web': True, - 'email': True, - 'push': True, + 'is_core': True, 'info': 'Response on post', 'non_editable': [], 'content_template': _('<{p}><{strong}>{replier_name} responded to your ' @@ -66,7 +60,7 @@ 'core_web': True, 'core_email': True, 'core_push': True, - 'non_editable': [] + 'non_editable': ['web'] } } diff --git a/openedx/core/djangoapps/notifications/models.py b/openedx/core/djangoapps/notifications/models.py index d89a8a6ea37b..14a9669b88a9 100644 --- a/openedx/core/djangoapps/notifications/models.py +++ b/openedx/core/djangoapps/notifications/models.py @@ -21,7 +21,7 @@ NOTIFICATION_CHANNELS = ['web', 'push', 'email'] # Update this version when there is a change to any course specific notification type or app. -COURSE_NOTIFICATION_CONFIG_VERSION = 1 +COURSE_NOTIFICATION_CONFIG_VERSION = 2 def get_course_notification_preference_config(): diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index ee0ea0c1b029..b35c469204a2 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -217,20 +217,8 @@ def _expected_api_response(self): 'notification_preference_config': { 'discussion': { 'enabled': True, - 'core_notification_types': ['new_comment_on_response'], + 'core_notification_types': ['new_comment_on_response', 'new_comment', 'new_response'], 'notification_types': { - 'new_comment': { - 'web': True, - 'email': True, - 'push': True, - 'info': 'Comment on post' - }, - 'new_response': { - 'web': True, - 'email': True, - 'push': True, - 'info': 'Response on post' - }, 'core': { 'web': True, 'email': True, @@ -239,7 +227,7 @@ def _expected_api_response(self): } }, 'non_editable': { - 'new_comment': ['web', 'email'] + 'core': ['web'] } } } @@ -269,9 +257,6 @@ def test_get_user_notification_preference(self, mock_emit): ('discussion', None, None, False, status.HTTP_200_OK, 'app_update'), ('invalid_notification_app', None, None, True, status.HTTP_400_BAD_REQUEST, None), - ('discussion', 'new_comment', 'web', True, status.HTTP_200_OK, 'type_update'), - ('discussion', 'new_response', 'web', False, status.HTTP_200_OK, 'type_update'), - ('discussion', 'core', 'email', True, status.HTTP_200_OK, 'type_update'), ('discussion', 'core', 'email', False, status.HTTP_200_OK, 'type_update'),