newmediamonitoring1/polls/decorators.py

12 lines
309 B
Python
Raw Normal View History

2020-09-03 04:03:19 +00:00
from django.http import HttpResponse
2020-09-04 14:42:41 +00:00
2020-09-03 04:03:19 +00:00
def polls_login_required(function):
def wrapper(request, *args, **kwargs):
u = request.user
2020-09-04 14:42:41 +00:00
if not u.is_authenticated:
2020-09-03 04:03:19 +00:00
return HttpResponse(status=401)
else:
return function(request, *args, **kwargs)
2020-09-04 14:42:41 +00:00
return wrapper