diff --git a/seminar/views/autocomplete.py b/seminar/views/autocomplete.py index f63ab5ac..13905fd6 100644 --- a/seminar/views/autocomplete.py +++ b/seminar/views/autocomplete.py @@ -33,15 +33,17 @@ class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): nastaveni = get_object_or_404(m.Nastaveni) rocnik = nastaveni.aktualni_rocnik - temata = m.Tema.objects.filter(rocnik=rocnik, stav=m.Problem.STAV_ZADANY) - ulohy = m.Uloha.objects.filter(cislo_deadline__rocnik = rocnik) - clanky = m.Clanek.objects.filter(cislo__rocnik = rocnik, stav=m.Problem.STAV_ZADANY) # FIXME: Je tohle to, co chceme? - print(temata, ulohy, clanky) - ulohy.union(temata, all=True) - print(ulohy) - ulohy.union(clanky, all=True) - print(ulohy) - qs = ulohy + # Od tohoto místa dál jsem zkoušel spoustu variací podle https://django-polymorphic.readthedocs.io/en/stable/advanced.html + temaQ = Q(Tema___rocnik = rocnik, stav=m.Problem.STAV_ZADANY) + ulohaQ = Q(Uloha___cislo_deadline__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) + #print(temata, ulohy, clanky) + #ulohy.union(temata, all=True) + #print(ulohy) + #ulohy.union(clanky, all=True) + #print(ulohy) + #qs = ulohy print(qs) if self.q: qs = qs.filter(