Merge branch '24-Fixing/fixing-read-unread-notification' into 'main'

save instance after changed field value

Closes #23

See merge request dev/yuyu!5
This commit is contained in:
Setyo Nugroho 2022-08-04 17:53:15 +00:00
commit 651d0f83fb

View file

@ -401,6 +401,7 @@ class NotificationViewSet(viewsets.ModelViewSet):
def set_read(self, request, pk): def set_read(self, request, pk):
notification = Notification.objects.filter(id=pk).first() notification = Notification.objects.filter(id=pk).first()
notification.is_read = True notification.is_read = True
notification.save()
serializer = NotificationSerializer(notification) serializer = NotificationSerializer(notification)
@ -410,6 +411,7 @@ class NotificationViewSet(viewsets.ModelViewSet):
def set_unread(self, request, pk): def set_unread(self, request, pk):
notification = Notification.objects.filter(id=pk).first() notification = Notification.objects.filter(id=pk).first()
notification.is_read = False notification.is_read = False
notification.save()
serializer = NotificationSerializer(notification) serializer = NotificationSerializer(notification)