.
This commit is contained in:
+4
-2
@@ -194,7 +194,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
#group_map = {"rapids" : "rapid_checker", "anatomy" : "anatomy_checker", "longs":"long_checker"}
|
||||
#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
|
||||
|
||||
Args:
|
||||
@@ -203,6 +203,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
Returns:
|
||||
[boolean]: True if the user has access
|
||||
"""
|
||||
if exam_id is not None:
|
||||
exam = get_object_or_404(self.Exam, pk=exam_id)
|
||||
if user in exam.get_author_objects():
|
||||
return True
|
||||
@@ -219,7 +220,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
return False
|
||||
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
|
||||
|
||||
Args:
|
||||
@@ -229,6 +230,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
[boolean]: True if the user has access
|
||||
"""
|
||||
# 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)
|
||||
if user in exam.get_author_objects():
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user