1
0
Fork 0

Merge pull request #538 from mouse-reeve/polling

Polling to update notification count
This commit is contained in:
Mouse Reeve 2021-01-19 15:13:37 -08:00 committed by GitHub
commit 0700a71803
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 12 deletions

View file

@ -23,4 +23,5 @@ from .shelf import Shelf
from .shelf import user_shelves_page, create_shelf, delete_shelf
from .shelf import shelve, unshelve
from .status import Status, Replies, CreateStatus, DeleteStatus
from .updates import Updates
from .user import User, EditUser, Followers, Following

17
bookwyrm/views/updates.py Normal file
View file

@ -0,0 +1,17 @@
''' endpoints for getting updates about activity '''
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from django.views import View
# pylint: disable= no-self-use
@method_decorator(login_required, name='dispatch')
class Updates(View):
''' so the app can poll '''
def get(self, request):
''' any notifications waiting? '''
return JsonResponse({
'notifications': request.user.notification_set.filter(
read=False
).count(),
})