From f1026c1a0635af3b0dcd3be0d3494afb4a66f298 Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Thu, 3 Sep 2020 22:00:54 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20logu=20v=20p=C5=99ihl=C3=A1=C5=A1ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/views_all.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 0144854a..e8298b17 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -1202,7 +1202,7 @@ def prihlaskaView(request): generic_logger.info("Form valid") fcd = form.cleaned_data form_hash = hash(frozenset(fcd.items())) - form_logger.info(fcd,form_hash) # TODO takhle log nefunguje, ale ta předchozí varianta dokonce padala + form_logger.info(str(fcd) + str(form_hash)) # TODO možná logovat jinak with transaction.atomic(): u = User.objects.create_user( @@ -1232,7 +1232,7 @@ def prihlaskaView(request): else: # Unknown country - log it msg = "Unknown country {}".format(fcd['stat_text']) - err_logger.warn(msg,form_hash) # TODO viz výše + err_logger.warn(msg + str(form_hash)) o.save() o.user = u @@ -1250,7 +1250,7 @@ def prihlaskaView(request): else: # Unknown school - log it msg = "Unknown school {}, {}".format(fcd['skola_nazev'],fcd['skola_adresa']) - err_logger.warn(msg,form_hash) # TODO viz výše + err_logger.warn(msg + str(form_hash)) r.save() From 714fb43eabac5d1ec0d00559471a90495ed395be Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Fri, 4 Sep 2020 15:37:04 +0200 Subject: [PATCH 2/2] 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):