From 728de9be067f04454b6408e5bdd00e44d531c818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Thu, 24 Nov 2022 20:41:17 +0100 Subject: [PATCH] =?UTF-8?q?hotfix:=20p=C5=99i=20vyb=C3=ADr=C3=A1n=C3=AD=20?= =?UTF-8?q?probl=C3=A9mu=20jsou=20vid=C4=9Bt=20i=20star=C3=A9=20ro=C4=8Dn?= =?UTF-8?q?=C3=ADky,=20ale=20sortit=20podle=20ro=C4=8Dn=C3=ADku=20neum?= =?UTF-8?q?=C3=ADm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views/autocomplete.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index 4cd2552a..8c6f334c 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -69,7 +69,13 @@ class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView): 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") + # FIXME i starší úlohy + nastaveni = get_object_or_404(m.Nastaveni) + rocnik = nastaveni.aktualni_rocnik + temaQ = Q(Tema___rocnik = rocnik, stav=m.Problem.STAV_ZADANY) + ulohaQ = Q(Uloha___cislo_zadani__rocnik = rocnik, stav=m.Problem.STAV_ZADANY) + clanekQ = Q(Clanek___cislo__rocnik = rocnik, stav=m.Problem.STAV_ZADANY) + qs = m.Problem.objects.filter(temaQ | ulohaQ | clanekQ).order_by("-stav", "nazev") if self.q: qs = qs.filter( Q(nazev__icontains=self.q))