From 7b5db01377070e7963a30c654331863b65123ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Thu, 24 Nov 2022 20:16:09 +0100 Subject: [PATCH] =?UTF-8?q?hotfix:=20org=20nem=C5=AF=C5=BEe=20p=C5=99i?= =?UTF-8?q?=C5=99adit=20hodnocen=C3=AD=20nezadan=C3=BD=20probl=C3=A9m=20(n?= =?UTF-8?q?ap=C5=99.=20vy=C5=99e=C5=A1en=C3=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/urls.py | 1 + api/views/autocomplete.py | 9 +++++++++ odevzdavatko/forms.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/api/urls.py b/api/urls.py index 23aafe36..2570ded9 100644 --- a/api/urls.py +++ b/api/urls.py @@ -23,6 +23,7 @@ urlpatterns = [ path('api/autocomplete/skola/', views.SkolaAutocomplete.as_view(), name='autocomplete_skola'), path('api/autocomplete/resitel/', org_required(views.ResitelAutocomplete.as_view()), name='autocomplete_resitel'), path('api/autocomplete/problem/odevzdatelny', views.OdevzdatelnyProblemAutocomplete.as_view(), name='autocomplete_problem_odevzdatelny'), + path('api/autocomplete/problem/vsechny', views.ProblemAutocomplete.as_view(), name='autocomplete_problem'), # Ceka na autocomplete v3 # path('autocomplete/organizatori/', diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index 217df008..4cd2552a 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -66,6 +66,15 @@ class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView): Q(nazev__icontains=self.q)) return qs +class ProblemAutocomplete(autocomplete.Select2QuerySetView): + """ View k :mod:`dal.autocomplete` pro vyhledávání problémů především v odevzdávátku. """ + def get_queryset(self): + qs = m.Problem.objects.all().order_by("-stav", "nazev") + if self.q: + qs = qs.filter( + Q(nazev__icontains=self.q)) + return qs + # Ceka na autocomplete v3 # class OrganizatorAutocomplete(autocomplete.Select2QuerySetView): # def get_queryset(self): diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index a8538668..65a8b7ac 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -91,7 +91,7 @@ class JednoHodnoceniForm(forms.ModelForm): fields = ('problem', 'body', 'deadline_body', 'feedback',) widgets = { 'problem': autocomplete.ModelSelect2( - url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší? + url='autocomplete_problem', ), 'feedback': forms.Textarea(attrs={'rows': 1, 'cols': 30, 'class': 'feedback'}), }