.
This commit is contained in:
+6
-6
@@ -157,6 +157,9 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
self.question_type = question_type
|
||||
self.loadJsonAnswer = loadJsonAnswer
|
||||
|
||||
group_map = {"rapids" : "rapid_checker", "anatomy" : "anatomy_checker", "longs":"long_checker"}
|
||||
exam_group = group_map[self.app_name]
|
||||
|
||||
def check_user_access(self, user):
|
||||
"""Check if a user should be able to access a view
|
||||
|
||||
@@ -383,11 +386,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
active_exams = {"exams": []}
|
||||
|
||||
group_map = {"rapids" : "rapid_checker", "anatomy" : "anatomy_checker", "longs":"long_checker"}
|
||||
exam_group = group_map[self.app_name]
|
||||
|
||||
for exam in exams:
|
||||
if exam.active or (request.user is not None and request.user.groups.filter(name=exam_group).exists()):
|
||||
if exam.active or self.check_user_access(request.user):
|
||||
if exam.json_creation_time:
|
||||
creation_time = exam.json_creation_time.isoformat()
|
||||
else:
|
||||
@@ -450,7 +450,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
"""
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
if not exam.active:
|
||||
if not exam.active or not self.check_user_access(request.user):
|
||||
raise Http404("No available exam")
|
||||
|
||||
exam_json = exam.get_exam_json(based=False)
|
||||
@@ -460,7 +460,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
if not exam.active:
|
||||
if not exam.active or not self.check_user_access(request.user):
|
||||
raise Http404("No available exam")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user