From 576113a8126ed8746115575b259f3152e5195513 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 1 Mar 2022 18:24:16 +0000 Subject: [PATCH] . --- anatomy/forms.py | 27 ++++++++++++++++++++------- longs/forms.py | 1 + rapids/forms.py | 10 +++++++++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/anatomy/forms.py b/anatomy/forms.py index 9bbbaff2..a0eee0a2 100644 --- a/anatomy/forms.py +++ b/anatomy/forms.py @@ -12,7 +12,7 @@ from .models import ( Answer, CidUserAnswer, AnatomyQuestion, - #Examination, + # Examination, BodyPart, Structure, Region, @@ -27,6 +27,7 @@ from django.forms.widgets import RadioSelect, TextInput, Textarea from dal import autocomplete + class AnatomyAnswerForm(ModelForm): class Meta: model = CidUserAnswer @@ -42,7 +43,7 @@ class MarkAnatomyQuestionForm(Form): class AnatomyQuestionForm(ModelForm): - #exams = ModelMultipleChoiceField(required=False, queryset=Exam.objects.all()) + # exams = ModelMultipleChoiceField(required=False, queryset=Exam.objects.all()) class Media: # Django also includes a few javascript files necessary @@ -56,7 +57,9 @@ class AnatomyQuestionForm(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. @@ -99,7 +102,9 @@ class AnatomyQuestionForm(ModelForm): if self.user.groups.filter(name="anatomy_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, @@ -107,7 +112,6 @@ class AnatomyQuestionForm(ModelForm): widget=FilteredSelectMultiple(verbose_name="Exams", is_stacked=False), ) - def save(self, commit=True): # Get the unsaved Pizza instance instance = ModelForm.save(self, False) @@ -143,7 +147,7 @@ class AnatomyQuestionForm(ModelForm): ] widgets = { - "structure" : autocomplete.ModelSelect2(url='anatomy:structure-autocomplete') + "structure": autocomplete.ModelSelect2(url="anatomy:structure-autocomplete") } @@ -195,7 +199,16 @@ class BodyPartForm(ModelForm): model = BodyPart fields = ["bodypart"] + class ExamForm(ModelForm): class Meta: model = Exam - fields = ["name", "time_limit", "open_access", "exam_mode", "active", "archive"] \ No newline at end of file + fields = [ + "name", + "time_limit", + "open_access", + "exam_mode", + "active", + "publish_results", + "archive", + ] diff --git a/longs/forms.py b/longs/forms.py index 13ce2661..39f89296 100755 --- a/longs/forms.py +++ b/longs/forms.py @@ -279,6 +279,7 @@ class ExamForm(ModelForm): "open_access", "exam_mode", "active", + "publish_results", "double_mark", "archive", ] diff --git a/rapids/forms.py b/rapids/forms.py index 80b50c01..baa84288 100755 --- a/rapids/forms.py +++ b/rapids/forms.py @@ -228,4 +228,12 @@ AnswerUpdateFormSet = inlineformset_factory( class ExamForm(ModelForm): class Meta: model = Exam - fields = ["name", "time_limit", "open_access", "exam_mode", "active", "archive"] + fields = [ + "name", + "time_limit", + "open_access", + "exam_mode", + "active", + "publish_results", + "archive", + ]