read or unread notification
This commit is contained in:
parent
58464033e9
commit
2503a904c8
1 changed files with 18 additions and 0 deletions
18
api/views.py
18
api/views.py
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue