mamweb/api/views/helpers.py

10 lines
467 B
Python
Raw Normal View History

2021-10-05 00:00:15 +02:00
from django.http import JsonResponse
2020-03-03 21:48:55 +01:00
class LoginRequiredAjaxMixin(object):
def dispatch(self, request, *args, **kwargs):
#if request.is_ajax() and not request.user.is_authenticated: # Pokud to otevřu jako stránku, tak se omezení neuplatní, takže to asi nechceme
if not request.user.is_authenticated:
return JsonResponse(data={'results': [], 'pagination': {}}, status=401)
return super(LoginRequiredAjaxMixin, self).dispatch(request, *args, **kwargs)