1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 23:02:26 +00:00

update get unseen notifications count

This commit is contained in:
lian
2016-08-19 12:00:05 +08:00
committed by lian
parent b4599bf6b0
commit 8d62d3786e
6 changed files with 56 additions and 19 deletions

View File

@@ -0,0 +1,26 @@
# Copyright (c) 2012-2016 Seafile Ltd.
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from seahub.api2.authentication import TokenAuthentication
from seahub.api2.throttling import UserRateThrottle
from seahub.notifications.models import UserNotification
json_content_type = 'application/json; charset=utf-8'
class NotificationsView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request):
username = request.user.username
unseen_count = UserNotification.objects.count_unseen_user_notifications(username)
result = {}
result['unseen_count'] = unseen_count
return Response(result)