From bf4b3c628b3be836c445a352d26cbddad10e3100 Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Wed, 21 Jun 2023 13:02:28 +0500 Subject: [PATCH] refactor: updated api reference from unseen to seen (#32501) --- .../djangoapps/notifications/tests/test_views.py | 12 ++++++------ openedx/core/djangoapps/notifications/urls.py | 8 ++++---- openedx/core/djangoapps/notifications/views.py | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index 8efd4d4619..84f7116964 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -489,7 +489,7 @@ class NotificationCountViewSetTestCase(ModuleStoreTestCase): self.assertEqual(response.data['count_by_app_name'], {}) -class MarkNotificationsUnseenAPIViewTestCase(APITestCase): +class MarkNotificationsSeenAPIViewTestCase(APITestCase): """ Tests for the MarkNotificationsUnseenAPIView. """ @@ -503,20 +503,20 @@ class MarkNotificationsUnseenAPIViewTestCase(APITestCase): Notification.objects.create(user=self.user, app_name='App Name 2', notification_type='Type A') Notification.objects.create(user=self.user, app_name='App Name 3', notification_type='Type C') - def test_mark_notifications_unseen(self): - # Create a POST request to mark notifications as unseen for 'App Name 1' + def test_mark_notifications_seen(self): + # Create a POST request to mark notifications as seen for 'App Name 1' app_name = 'App Name 1' - url = reverse('mark-notifications-unseen', kwargs={'app_name': app_name}) + url = reverse('mark-notifications-seen', kwargs={'app_name': app_name}) self.client.login(username=self.user.username, password='test') response = self.client.put(url) # Assert the response status code is 200 (OK) self.assertEqual(response.status_code, status.HTTP_200_OK) # Assert the response data contains the expected message - expected_data = {'message': 'Notifications marked unseen.'} + expected_data = {'message': 'Notifications marked as seen.'} self.assertEqual(response.data, expected_data) - # Assert the notifications for 'App Name 1' are marked as unseen for the user + # Assert the notifications for 'App Name 1' are marked as seen for the user notifications = Notification.objects.filter(user=self.user, app_name=app_name, last_seen__isnull=False) self.assertEqual(notifications.count(), 2) diff --git a/openedx/core/djangoapps/notifications/urls.py b/openedx/core/djangoapps/notifications/urls.py index f4638ea7de..ca20774ac5 100644 --- a/openedx/core/djangoapps/notifications/urls.py +++ b/openedx/core/djangoapps/notifications/urls.py @@ -7,7 +7,7 @@ from rest_framework import routers from .views import ( CourseEnrollmentListView, - MarkNotificationsUnseenAPIView, + MarkNotificationsSeenAPIView, NotificationCountView, NotificationListAPIView, NotificationReadAPIView, @@ -27,9 +27,9 @@ urlpatterns = [ path('', NotificationListAPIView.as_view(), name='notifications-list'), path('count/', NotificationCountView.as_view(), name='notifications-count'), path( - 'mark-notifications-unseen//', - MarkNotificationsUnseenAPIView.as_view(), - name='mark-notifications-unseen' + 'mark-seen//', + MarkNotificationsSeenAPIView.as_view(), + name='mark-notifications-seen' ), path('read/', NotificationReadAPIView.as_view(), name='notifications-read'), diff --git a/openedx/core/djangoapps/notifications/views.py b/openedx/core/djangoapps/notifications/views.py index 4bf319022b..04543dc524 100644 --- a/openedx/core/djangoapps/notifications/views.py +++ b/openedx/core/djangoapps/notifications/views.py @@ -301,21 +301,21 @@ class NotificationCountView(APIView): }) -class MarkNotificationsUnseenAPIView(UpdateAPIView): +class MarkNotificationsSeenAPIView(UpdateAPIView): """ - API view for marking user's all notifications unseen for a provided app_name. + API view for marking user's all notifications seen for a provided app_name. """ permission_classes = (permissions.IsAuthenticated,) def update(self, request, *args, **kwargs): """ - Marks all notifications for the given app name unseen for the authenticated user. + Marks all notifications for the given app name seen for the authenticated user. **Args:** - app_name: The name of the app to mark notifications unseen for. + app_name: The name of the app to mark notifications seen for. **Response Format:** - A `Response` object with a 200 OK status code if the notifications were successfully marked unseen. + A `Response` object with a 200 OK status code if the notifications were successfully marked seen. **Response Error Codes**: - 400: Bad Request status code if the app name is invalid. """ @@ -332,7 +332,7 @@ class MarkNotificationsUnseenAPIView(UpdateAPIView): notifications.update(last_seen=datetime.now()) - return Response({'message': _('Notifications marked unseen.')}, status=200) + return Response({'message': _('Notifications marked as seen.')}, status=200) class NotificationReadAPIView(APIView):