.
This commit is contained in:
+10
-8
@@ -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,9 +203,10 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
Returns:
|
||||
[boolean]: True if the user has access
|
||||
"""
|
||||
exam = get_object_or_404(self.Exam, pk=exam_id)
|
||||
if user in exam.get_author_objects():
|
||||
return True
|
||||
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
|
||||
|
||||
if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists():
|
||||
return False
|
||||
@@ -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,9 +230,10 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
[boolean]: True if the user has access
|
||||
"""
|
||||
# If a user is an exam author they should have acccess
|
||||
exam = get_object_or_404(self.Exam, pk=exam_id)
|
||||
if user in exam.get_author_objects():
|
||||
return True
|
||||
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
|
||||
|
||||
if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists():
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user