From d7898c39b1a1e4b1da137a1931167530c8ac6500 Mon Sep 17 00:00:00 2001 From: "Pavel Turinsky (DebianVM @ Zr)" Date: Tue, 22 Jun 2021 22:29:11 +0000 Subject: [PATCH] Spravnejsi vyrobeni treenodu pro clanek --- seminar/migrations/0058_problem_to_uloha_tema_clanek.py | 4 +++- seminar/migrations/0060_spoj_stromy.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py index e228f240..14255696 100644 --- a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py +++ b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py @@ -114,7 +114,7 @@ def Clanek_Treenody(apps, schema_editor): TextNode = apps.get_model('seminar', 'TextNode') for cl in Clanek.objects.all(): # Vyrobíme nody: - # Clanek nema vlastni node, ma (prave jedno) Reseni a to ma ReseniNode + # Clanek nema vlastni node, ma (prave jedno) Reseni a to ma text_cely -- ReseniNode reseni = cl.reseni_set.all() if len(reseni) != 1: raise ValueError(f'Clanek {cl.id} ma vic reseni {len(reseni)} ({reseni})') @@ -122,6 +122,8 @@ def Clanek_Treenody(apps, schema_editor): resnode = ReseniNode(reseni=reseni) poskladej_strom(apps, resnode, cl.text_zadani, cl.text_reseni) resnode.save() + reseni.text_cely = resnode + reseni.save() def fix_Clanek_Reseni(apps, schema_editor): Problem = apps.get_model('seminar', 'Problem') diff --git a/seminar/migrations/0060_spoj_stromy.py b/seminar/migrations/0060_spoj_stromy.py index c02b8d12..f6832abd 100644 --- a/seminar/migrations/0060_spoj_stromy.py +++ b/seminar/migrations/0060_spoj_stromy.py @@ -85,8 +85,12 @@ def pokacej_les(apps, schema_editor): # Články for cl in Clanek.objects.filter(cislo = c).order_by('kod'): - clnode = cl.claneknode - pridej_potomka(cnode, clnode) + # Zmena: Clanky nemaji vlastni Node, ale pouziva se ReseniNode v text_cely + reseni = cl.reseni_set.all() + if len(reseni) != 1: + raise ValueError('Clanek ma vic reseni') + resnode = reseni[0].text_cely + pridej_potomka(cnode, resnode) # Konfery for k in Konfera.objects.all():