.
This commit is contained in:
+7
-5
@@ -77,7 +77,9 @@ class RapidForm(ModelForm):
|
||||
js = ["jsi18n.js", "tesseract.min.js"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user') # To get request.user. Do not use kwargs.pop('user', None) due to potential security hole
|
||||
self.user = kwargs.pop(
|
||||
"user"
|
||||
) # To get request.user. Do not use kwargs.pop('user', None) due to potential security hole
|
||||
if kwargs.get("instance"):
|
||||
# We get the 'initial' keyword argument or initialize it
|
||||
# as a dict if it didn't exist.
|
||||
@@ -115,8 +117,9 @@ class RapidForm(ModelForm):
|
||||
if self.user.groups.filter(name="rapid_checker").exists():
|
||||
exam_queryset = Exam.objects.all()
|
||||
else:
|
||||
exam_queryset = Exam.objects.filter(author__id=self.user.id) | Exam.objects.filter(open_access=True)
|
||||
|
||||
exam_queryset = Exam.objects.filter(
|
||||
author__id=self.user.id
|
||||
) | Exam.objects.filter(open_access=True)
|
||||
|
||||
self.fields["exams"] = ModelMultipleChoiceField(
|
||||
required=False,
|
||||
@@ -133,7 +136,6 @@ class RapidForm(ModelForm):
|
||||
# exam = Exam.objects.get(pk=exam_pk)
|
||||
exam.exam_questions.add(instance)
|
||||
|
||||
|
||||
# # Prepare a 'save_m2m' method for the form,
|
||||
# old_save_m2m = self.save_m2m
|
||||
#
|
||||
@@ -149,7 +151,7 @@ class RapidForm(ModelForm):
|
||||
# # Do we need to save all changes now?
|
||||
# # if commit:
|
||||
# instance.save()
|
||||
# self.save_m2m()
|
||||
self.save_m2m()
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user