Skip to content

Commit

Permalink
- Add support for filtering the notification list API by read status.
Browse files Browse the repository at this point in the history
- Show only unread notification on the badge.

Signed-off-by: Eric Riggs <ericriggs42@gmail.com>
  • Loading branch information
eriggs authored and siloraptor committed Apr 1, 2018
1 parent 98c61bf commit cc7eb92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion mayan/apps/events/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion mayan/apps/events/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_notification_count(context):
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'
)

0 comments on commit cc7eb92

Please sign in to comment.