From cc7eb925509a6623b6bcf1efa3fdaa2a3faa71c3 Mon Sep 17 00:00:00 2001 From: Eric Riggs Date: Thu, 8 Mar 2018 04:28:30 -0400 Subject: [PATCH] - Add support for filtering the notification list API by read status. - Show only unread notification on the badge. Signed-off-by: Eric Riggs --- mayan/apps/events/api_views.py | 11 ++++++++++- mayan/apps/events/links.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mayan/apps/events/api_views.py b/mayan/apps/events/api_views.py index 227e813c9b..396ea31d65 100644 --- a/mayan/apps/events/api_views.py +++ b/mayan/apps/events/api_views.py @@ -143,4 +143,13 @@ class APINotificationListView(generics.ListAPIView): serializer_class = NotificationSerializer def get_queryset(self): - return Notification.objects.filter(user=self.request.user) + parameter_read = self.request.GET.get('read') + + queryset = Notification.objects.filter(user=self.request.user) + + if parameter_read == 'True': + queryset = queryset.filter(read=True) + elif parameter_read == 'False': + queryset = queryset.filter(read=False) + + return queryset diff --git a/mayan/apps/events/links.py b/mayan/apps/events/links.py index 0d50cc7a76..bae4ecbf57 100644 --- a/mayan/apps/events/links.py +++ b/mayan/apps/events/links.py @@ -70,7 +70,7 @@ link_user_events = Link( link_user_notifications_list = Link( html_data={ 'apw-attribute': 'count', 'apw-interval': '5000', - 'apw-url': '/api/notifications/', + 'apw-url': '/api/notifications/?read=False', 'apw-callback': 'App.mayanNotificationBadge' }, icon='fa fa-bell', text='', view='events:user_notifications_list' )