.
This commit is contained in:
+11
-5
@@ -145,6 +145,16 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
self.question_type = question_type
|
self.question_type = question_type
|
||||||
self.loadJsonAnswer = loadJsonAnswer
|
self.loadJsonAnswer = loadJsonAnswer
|
||||||
|
|
||||||
|
def check_user_access(user):
|
||||||
|
if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists():
|
||||||
|
return False
|
||||||
|
if self.app_name == "anatomy" and not user.groups.filter(name='anatomy_checker').exists():
|
||||||
|
return False
|
||||||
|
if self.app_name == "longs" and not user.groups.filter(name='long_checker').exists():
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def exam_toggle_results_published(self, request, pk):
|
def exam_toggle_results_published(self, request, pk):
|
||||||
if request.is_ajax() and request.method == "POST":
|
if request.is_ajax() and request.method == "POST":
|
||||||
@@ -200,11 +210,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
def exam_list(self, request):
|
def exam_list(self, request):
|
||||||
exams = self.Exam.objects.filter(exam_mode=True)
|
exams = self.Exam.objects.filter(exam_mode=True)
|
||||||
|
|
||||||
if self.app_name == "rapids" and not request.user.groups.filter(name='rapid_checker').exists():
|
if not self.check_user_access(request.user)
|
||||||
raise PermissionDenied
|
|
||||||
if self.app_name == "anatomy" and not request.user.groups.filter(name='anatomy_checker').exists():
|
|
||||||
raise PermissionDenied
|
|
||||||
if self.app_name == "longs" and not request.user.groups.filter(name='long_checker').exists():
|
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
return render(request, "{}/exam_list.html".format(self.app_name), {"exams": exams})
|
return render(request, "{}/exam_list.html".format(self.app_name), {"exams": exams})
|
||||||
|
|||||||
Reference in New Issue
Block a user