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:
26
seahub/api2/endpoints/notifications.py
Normal file
26
seahub/api2/endpoints/notifications.py
Normal 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)
|
Reference in New Issue
Block a user