From 56e1484b87464d508532482acae5b8001b12472d Mon Sep 17 00:00:00 2001 From: abutalib-kiwi Date: Wed, 23 Aug 2023 12:54:39 +0530 Subject: [PATCH] mark ad read api modified --- notifications/serializers.py | 2 ++ notifications/views.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/notifications/serializers.py b/notifications/serializers.py index 14f1b20..2f0222f 100644 --- a/notifications/serializers.py +++ b/notifications/serializers.py @@ -40,6 +40,8 @@ class NotificationListSerializer(serializers.ModelSerializer): class ReadNotificationSerializer(serializers.ModelSerializer): """User task Serializer""" + id = serializers.ListSerializer(child=serializers.IntegerField()) + class Meta(object): """Meta class""" model = Notification diff --git a/notifications/views.py b/notifications/views.py index 8674e85..d60c429 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -55,10 +55,11 @@ class NotificationViewSet(viewsets.GenericViewSet): {'task_id': None}) return custom_response(SUCCESS_CODE["3000"]) - @action(methods=['get'], url_path='mark-as-read', url_name='mark-as-read', detail=True, ) + @action(methods=['patch'], url_path='mark-as-read', url_name='mark-as-read', detail=False, + serializer_class=ReadNotificationSerializer) def mark_as_read(self, request, *args, **kwargs): """ notification list """ - Notification.objects.filter(id=kwargs['pk']).update(is_read=True) + Notification.objects.filter(id__in=request.data.get('id')).update(is_read=True) return custom_response(SUCCESS_CODE['3039'], response_status=status.HTTP_200_OK)