read or unread notification

This commit is contained in:
Setyo Nugroho 2022-07-08 14:51:08 +07:00
parent 58464033e9
commit 2503a904c8

View file

@ -389,3 +389,21 @@ class NotificationViewSet(viewsets.ModelViewSet):
serializer = NotificationSerializer(notification)
return Response(serializer.data)
@action(detail=True, methods=['GET'])
def set_read(self, request, pk):
notification = Notification.objects.filter(id=pk).first()
notification.is_read = True
serializer = NotificationSerializer(notification)
return Response(serializer.data)
@action(detail=True, methods=['GET'])
def set_unread(self, request, pk):
notification = Notification.objects.filter(id=pk).first()
notification.is_read = False
serializer = NotificationSerializer(notification)
return Response(serializer.data)