This commit is contained in:
Ross
2021-04-29 23:18:40 +01:00
parent e4a0431f63
commit d4ae7dbf6c
3 changed files with 17 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
from django.core.exceptions import PermissionDenied
from .models import Exam, AnatomyQuestion
def user_is_author_or_anatomy_checker(function):
def wrap(request, *args, **kwargs):
question = AnatomyQuestion.objects.get(pk=kwargs['pk'])
if request.user in question.author.all() or request.user.groups.filter(name='anatomy_checker').exists():
return function(request, *args, **kwargs)
else:
raise PermissionDenied
wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap