This commit is contained in:
Ross
2021-04-22 13:09:53 +01:00
parent c1de563be1
commit de7287f51b
2 changed files with 13 additions and 11 deletions
+10 -10
View File
@@ -1,13 +1,13 @@
from django.core.exceptions import PermissionDenied
from .models import ExamBase
def user_is_exam_author_or_exam_checker(function):
def wrap(request, *args, **kwargs):
exam = Exam.objects.get(pk=kwargs['pk'])
if request.user in exam.author.all() or request.user.groups.filter(name='exam_checker').exists():
return function(request, *args, **kwargs)
else:
raise PermissionDenied
wrap.__doc__ = function.__doc__
#wrap.__name__ = function.__name__
return wrap
#def user_is_exam_author_or_exam_checker(function):
# def wrap(request, *args, **kwargs):
# exam = Exam.objects.get(pk=kwargs['pk'])
# if request.user in exam.author.all() or request.user.groups.filter(name='exam_checker').exists():
# return function(request, *args, **kwargs)
# else:
# raise PermissionDenied
# wrap.__doc__ = function.__doc__
# #wrap.__name__ = function.__name__
# return wrap