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