From fbcfe7e93fcb79af62079960cfaeb8eee5d58ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 May 2023 22:00:37 +0200 Subject: [PATCH] =?UTF-8?q?Odevzd=C3=A1v=C3=A1tko:=20Filtrovat=20pouze=20o?= =?UTF-8?q?devzdateln=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odevzdavatko/views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index acef1669..9a49cbc3 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -386,7 +386,15 @@ class NahrajReseniNadproblemView(LoginRequiredMixin, ListView): template_name = 'odevzdavatko/nahraj_reseni_nadproblem.html' def get_queryset(self): - return super().get_queryset().filter(nadproblem__isnull=True) + # COPY PASTE z api/views/autocomplete.py TODO hodit někam do utils? + nastaveni = get_object_or_404(m.Nastaveni) + rocnik = nastaveni.aktualni_rocnik + # 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_zadani__rocnik=rocnik, stav=m.Problem.STAV_ZADANY) + clanekQ = Q(Clanek___cislo__rocnik=rocnik, stav=m.Problem.STAV_ZADANY) + qs = super().get_queryset().filter(temaQ | ulohaQ | clanekQ) + return qs.filter(nadproblem__isnull=True) class NahrajReseniView(LoginRequiredMixin, CreateView):