From c93fa6c5744e6bfbc818da3579456629af29bf20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 22 May 2023 23:34:37 +0200 Subject: [PATCH] =?UTF-8?q?oprava=20=E2=80=9EVlo=C5=BEit=20=C5=99e=C5=A1en?= =?UTF-8?q?=C3=AD:=20v=C3=ADce=20=C5=99e=C5=A1itel=C5=AF=E2=80=9C=20a=20v?= =?UTF-8?q?=C3=ADce=20=C5=99e=C5=A1en=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odevzdavatko/forms.py | 16 +++++++++++++--- odevzdavatko/views.py | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index 2d2a8990..1a4e0a74 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -21,13 +21,23 @@ class DateInput(forms.DateInput): class PosliReseniForm(forms.Form): - #FIXME jen podproblémy daného problému - problem = forms.ModelChoiceField(label='Problém',queryset=m.Problem.objects.all()) + problem = forms.ModelMultipleChoiceField( + queryset=m.Problem.objects.all(), + label="Problémy", + widget=autocomplete.ModelSelect2Multiple( + url='autocomplete_problem_odevzdatelny', + attrs={ + 'data-placeholder--id': '-1', + 'data-placeholder--text': '---', + 'data-allow-clear': 'true' + }, + ), + ) # to_field_name #problem = models.ManyToManyField(Problem, verbose_name='problém', help_text='Problém', # through='Hodnoceni') - resitel = forms.ModelChoiceField(label="Řešitel", + resitel = forms.ModelMultipleChoiceField(label="Řešitelé", queryset=Resitel.objects.all(), widget=autocomplete.ModelSelect2Multiple( url='autocomplete_resitel', diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index d3c74812..5660af71 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -360,8 +360,8 @@ class PosliReseniView(LoginRequiredMixin, FormView): forma=data['forma'], poznamka=data['poznamka'], ) - nove_reseni.resitele.add(data['resitel']) - nove_reseni.problem.add(data['problem']) + nove_reseni.resitele.add(*data['resitel']) + nove_reseni.problem.add(*data['problem']) nove_reseni.save() context = self.get_context_data()