.
This commit is contained in:
+4
-3
@@ -83,7 +83,7 @@ class RapidForm(ModelForm):
|
|||||||
# Adding this javascript is crucial
|
# Adding this javascript is crucial
|
||||||
js = ["jsi18n.js", "tesseract.min.js"]
|
js = ["jsi18n.js", "tesseract.min.js"]
|
||||||
|
|
||||||
def __init__(self, user, *args, **kwargs):
|
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"):
|
if kwargs.get("instance"):
|
||||||
# We get the 'initial' keyword argument or initialize it
|
# We get the 'initial' keyword argument or initialize it
|
||||||
@@ -120,9 +120,10 @@ class RapidForm(ModelForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.user.groups.filter(name="rapid_checker").exists():
|
if self.user.groups.filter(name="rapid_checker").exists():
|
||||||
return Exam.objects.all()
|
exam_queryset = Exam.objects.all()
|
||||||
|
else:
|
||||||
|
exam_queryset = Exam.objects.filter(author__id=self.user.id)
|
||||||
|
|
||||||
exam_queryset = Exam.objects.filter(author__id=self.user.id)
|
|
||||||
|
|
||||||
self.fields["exams"] = ModelMultipleChoiceField(
|
self.fields["exams"] = ModelMultipleChoiceField(
|
||||||
required=False,
|
required=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user