moviewyrm/bookwyrm/views/updates.py

21 lines
635 B
Python
Raw Normal View History

2021-03-08 16:49:10 +00:00
""" endpoints for getting updates about activity """
2021-01-19 00:32:02 +00:00
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
2021-03-08 16:49:10 +00:00
@method_decorator(login_required, name="dispatch")
2021-01-19 00:32:02 +00:00
class Updates(View):
2021-03-08 16:49:10 +00:00
""" so the app can poll """
2021-01-19 00:32:02 +00:00
def get(self, request):
2021-03-08 16:49:10 +00:00
""" any notifications waiting? """
return JsonResponse(
{
"notifications": request.user.notification_set.filter(
read=False
).count(),
}
)