Skip to content

Commit acad883

Browse files
fix: added info in notification preferences (#37295)
1 parent 25522ef commit acad883

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

openedx/core/djangoapps/notifications/tests/test_views.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
from openedx.core.djangoapps.notifications.models import (
3131
CourseNotificationPreference, Notification, NotificationPreference
3232
)
33-
from openedx.core.djangoapps.notifications.serializers import add_non_editable_in_preference
33+
from openedx.core.djangoapps.notifications.serializers import (
34+
add_info_to_notification_config,
35+
add_non_editable_in_preference
36+
)
3437
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
3538
from xmodule.modulestore.tests.factories import CourseFactory
3639

@@ -711,6 +714,7 @@ def test_get_notification_preferences(self, role_type, role, visible_apps, hidde
711714

712715
expected_data = exclude_inaccessible_preferences(self.default_data['data'], self.user)
713716
expected_data = add_non_editable_in_preference(expected_data)
717+
expected_data = add_info_to_notification_config(expected_data)
714718

715719
self.assertEqual(response.data['data'], expected_data)
716720

@@ -768,25 +772,30 @@ def test_if_data_is_correctly_aggregated(self):
768772
"web": False,
769773
"email": False,
770774
"push": False,
771-
"email_cadence": "Daily"
775+
"email_cadence": "Daily",
776+
"info": ""
772777
},
773778
"new_question_post": {
774779
"web": False,
775780
"email": False,
776781
"push": False,
777-
"email_cadence": "Daily"
782+
"email_cadence": "Daily",
783+
"info": ""
778784
},
779785
"new_instructor_all_learners_post": {
780786
"web": False,
781787
"email": False,
782788
"push": False,
783-
"email_cadence": "Daily"
789+
"email_cadence": "Daily",
790+
"info": ""
784791
},
785792
"core": {
786793
"web": False,
787794
"email": False,
788795
"push": False,
789-
"email_cadence": "Daily"
796+
"email_cadence": "Daily",
797+
"info": "Notifications for responses and comments on your posts, and the ones you’re "
798+
"following, including endorsements to your responses and on your posts."
790799
}
791800
},
792801
"non_editable": {
@@ -803,13 +812,15 @@ def test_if_data_is_correctly_aggregated(self):
803812
"web": False,
804813
"email": False,
805814
"push": False,
806-
"email_cadence": "Daily"
815+
"email_cadence": "Daily",
816+
"info": ""
807817
},
808818
"core": {
809819
"web": True,
810820
"email": True,
811821
"push": True,
812-
"email_cadence": "Daily"
822+
"email_cadence": "Daily",
823+
"info": "Notifications for new announcements and updates from the course team."
813824
}
814825
},
815826
"non_editable": {
@@ -824,13 +835,15 @@ def test_if_data_is_correctly_aggregated(self):
824835
"web": False,
825836
"email": False,
826837
"push": False,
827-
"email_cadence": "Daily"
838+
"email_cadence": "Daily",
839+
"info": ""
828840
},
829841
"core": {
830842
"web": True,
831843
"email": True,
832844
"push": True,
833-
"email_cadence": "Daily"
845+
"email_cadence": "Daily",
846+
"info": "Notifications for submission grading."
834847
}
835848
},
836849
"non_editable": {

openedx/core/djangoapps/notifications/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .serializers import (
3232
NotificationSerializer,
3333
UserNotificationPreferenceUpdateAllSerializer,
34+
add_info_to_notification_config,
3435
add_non_editable_in_preference
3536
)
3637
from .tasks import create_notification_preference
@@ -323,11 +324,14 @@ def get(self, request):
323324
type_details['push'] = user_pref.push
324325
type_details['email_cadence'] = user_pref.email_cadence
325326
exclude_inaccessible_preferences(structured_preferences, request.user)
327+
structured_preferences = add_non_editable_in_preference(
328+
add_info_to_notification_config(structured_preferences)
329+
)
326330
return Response({
327331
'status': 'success',
328332
'message': 'Notification preferences retrieved successfully.',
329333
'show_preferences': get_show_notifications_tray(self.request.user),
330-
'data': add_non_editable_in_preference(structured_preferences)
334+
'data': structured_preferences
331335
}, status=status.HTTP_200_OK)
332336

333337
def put(self, request):

0 commit comments

Comments
 (0)