stage starting django ninja
This commit is contained in:
@@ -3,7 +3,14 @@ from .models import Exam, Rapid
|
||||
|
||||
def user_is_author_or_rapid_checker(function):
|
||||
def wrap(request, *args, **kwargs):
|
||||
question = Rapid.objects.get(pk=kwargs['pk'])
|
||||
if "pk" in kwargs:
|
||||
question_id = kwargs["pk"]
|
||||
elif "question_id" in kwargs:
|
||||
question_id = kwargs["question_id"]
|
||||
else:
|
||||
raise PermissionDenied
|
||||
|
||||
question = Rapid.objects.get(pk=question_id)
|
||||
if request.user in question.author.all() or request.user.groups.filter(name='rapid_checker').exists():
|
||||
return function(request, *args, **kwargs)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user