From 6255c9c957d16f996a2473d369a8ae05376c265d Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Sun, 5 Sep 2021 09:49:09 +0200 Subject: [PATCH] =?UTF-8?q?Prozat=C3=ADmn=C3=AD=20zve=C5=99ej=C5=88ov?= =?UTF-8?q?=C3=A1n=C3=AD=20=C4=8D=C3=ADsla=20spolu=20s=20jeho=20=C3=9Aloha?= =?UTF-8?q?mi=20a=20T=C3=A9maty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/admin.py | 50 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index e43d0cfd..49bf80f3 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -10,6 +10,9 @@ from django_reverse_admin import ReverseModelAdmin from solo.admin import SingletonModelAdmin from django.utils.safestring import mark_safe +from seminar.views.vysledkovka import hlavni_problem +# TODO Přesunout do utils + # Todo: reversion @@ -58,23 +61,36 @@ class CisloAdmin(admin.ModelAdmin): def force_publish(self,request,queryset): for cislo in queryset: - cn = m.CisloNode.objects.get(cislo=cislo) - for ch in tl.all_children(cn): - print(ch) - if isinstance(ch, m.TemaVCisleNode): - if ch.tema.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): - ch.tema.stav = m.Problem.STAV_ZADANY - ch.tema.save() - - if isinstance(ch, m.UlohaZadaniNode) or isinstance(ch, m.UlohaVzorakNode): - if ch.uloha.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): - ch.uloha.stav = m.Problem.STAV_ZADANY - ch.uloha.save() - if isinstance(ch, m.ReseniNode): - for problem in ch.reseni.problem_set: - if problem not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): - problem.stav = m.Problem.STAV_ZADANY - problem.save() + # cn = m.CisloNode.objects.get(cislo=cislo) + # for ch in tl.all_children(cn): + # if isinstance(ch, m.TemaVCisleNode): + # if ch.tema.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): + # ch.tema.stav = m.Problem.STAV_ZADANY + # ch.tema.save() + # + # if isinstance(ch, m.UlohaZadaniNode) or isinstance(ch, m.UlohaVzorakNode): + # if ch.uloha.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): + # ch.uloha.stav = m.Problem.STAV_ZADANY + # ch.uloha.save() + # if isinstance(ch, m.ReseniNode): + # for problem in ch.reseni.problem_set: + # if problem not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): + # problem.stav = m.Problem.STAV_ZADANY + # problem.save() + + for ch in m.Uloha.objects.filter(cislo_zadani=cislo): + if ch.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): + ch.stav = m.Problem.STAV_ZADANY + ch.save() + + hp = hlavni_problem(ch) + if hp.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): + hp.stav = m.Problem.STAV_ZADANY + hp.save() + + # TODO Řešení, vzoráky? + # TODO Konfera/Článek? + cislo.verejne_db = True cislo.save()