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
2021-03-24 15:12:03 +00:00
from django.utils.decorators import method_decorator
from django.views import View
2021-01-19 00:32:02 +00:00
2021-03-24 15:12:03 +00:00
# pylint: disable= no-self-use
@method_decorator(login_required, name="dispatch")
class Updates(View):
""" so the app can poll """
2021-03-08 16:49:10 +00:00
2021-03-24 15:12:03 +00:00
def get(self, request):
""" any notifications waiting? """
return JsonResponse(
{
"notifications": request.user.notification_set.filter(
read=False
).count(),
}
)