This commit is contained in:
Ross
2021-10-17 10:14:40 +01:00
parent 6196a81989
commit b4ccacdcce
+4 -2
View File
@@ -194,7 +194,7 @@ class ExamViews(View, LoginRequiredMixin):
#group_map = {"rapids" : "rapid_checker", "anatomy" : "anatomy_checker", "longs":"long_checker"} #group_map = {"rapids" : "rapid_checker", "anatomy" : "anatomy_checker", "longs":"long_checker"}
#exam_group = group_map[self.app_name] #exam_group = group_map[self.app_name]
def check_user_access(self, user, exam_id): def check_user_access(self, user, exam_id=None):
"""Check if a user should be able to access a view """Check if a user should be able to access a view
Args: Args:
@@ -203,6 +203,7 @@ class ExamViews(View, LoginRequiredMixin):
Returns: Returns:
[boolean]: True if the user has access [boolean]: True if the user has access
""" """
if exam_id is not None:
exam = get_object_or_404(self.Exam, pk=exam_id) exam = get_object_or_404(self.Exam, pk=exam_id)
if user in exam.get_author_objects(): if user in exam.get_author_objects():
return True return True
@@ -219,7 +220,7 @@ class ExamViews(View, LoginRequiredMixin):
return False return False
return True return True
def check_user_edit_access(self, user, exam_id): def check_user_edit_access(self, user, exam_id=None):
"""Check if a user should be able to access a view """Check if a user should be able to access a view
Args: Args:
@@ -229,6 +230,7 @@ class ExamViews(View, LoginRequiredMixin):
[boolean]: True if the user has access [boolean]: True if the user has access
""" """
# If a user is an exam author they should have acccess # If a user is an exam author they should have acccess
if exam_id is not None:
exam = get_object_or_404(self.Exam, pk=exam_id) exam = get_object_or_404(self.Exam, pk=exam_id)
if user in exam.get_author_objects(): if user in exam.get_author_objects():
return True return True