some reset ansnwer improvements

This commit is contained in:
Ross
2024-07-29 13:05:09 +01:00
parent 88584f4c37
commit a304c0b4dc
3 changed files with 9 additions and 5 deletions
+6 -5
View File
@@ -502,7 +502,10 @@ class ExamViews(View, LoginRequiredMixin):
# 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 exam.open_access or user in exam.get_author_objects():
# Remove open_access check for the momement
#if exam.open_access or user in exam.get_author_objects():
# return True
if user in exam.get_author_objects():
return True
if exam.authors_only:
@@ -1046,10 +1049,8 @@ class ExamViews(View, LoginRequiredMixin):
if request.htmx:
exam = get_object_or_404(self.Exam, pk=exam_id)
if not request.user.groups.filter(name="cid_user_manager").exists():
# raise PermissionDenied
if request.user not in exam.author.all():
raise PermissionDenied
if not self.check_user_edit_access(request.user, exam_id):
raise PermissionDenied
## Delete all answers
exam.cid_user_answers.all().delete()