From 714fb43eabac5d1ec0d00559471a90495ed395be Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Fri, 4 Sep 2020 15:37:04 +0200 Subject: [PATCH] Pokus o opravu ClankyResitelView --- seminar/views/views_all.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 0144854a..d57fb221 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -1012,19 +1012,21 @@ def group_by_rocnik(clanky): # FIXME: clanky jsou vsechny, pokud budou i neresitelske, tak se take zobrazi +# FIXME: Původně tu byl kód přímo v těle třídy, což rozbíjelo migrace. Opravil jsem, ale vůbec nevím, jestli to funguje. class ClankyResitelView(generic.ListView): model = Problem template_name = 'seminar/clanky/resitelske_clanky.html' - #queryset - clanky = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo__rocnik').order_by('-cislo__rocnik__rocnik') - queryset = [] - skupiny_clanku = group_by_rocnik(clanky) - for skupina in skupiny_clanku: - skupina.sort(key=lambda clanek: clanek.kod_v_rocniku()) - for clanek in skupina: - queryset.append(clanek) - - #zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod') + + # FIXME: QuerySet není pole! + def get_queryset(self): + clanky = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo__rocnik').order_by('-cislo__rocnik__rocnik') + queryset = [] + skupiny_clanku = group_by_rocnik(clanky) + for skupina in skupiny_clanku: + skupina.sort(key=lambda clanek: clanek.kod_v_rocniku()) + for clanek in skupina: + queryset.append(clanek) + return queryset # FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit #class ClankyOrganizatorView(generic.ListView):