Browse Source

Spravnejsi vyrobeni treenodu pro clanek

middleware_test
Pavel Turinsky (DebianVM @ Zr) 3 years ago
parent
commit
d7898c39b1
  1. 4
      seminar/migrations/0058_problem_to_uloha_tema_clanek.py
  2. 8
      seminar/migrations/0060_spoj_stromy.py

4
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') TextNode = apps.get_model('seminar', 'TextNode')
for cl in Clanek.objects.all(): for cl in Clanek.objects.all():
# Vyrobíme nody: # 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() reseni = cl.reseni_set.all()
if len(reseni) != 1: if len(reseni) != 1:
raise ValueError(f'Clanek {cl.id} ma vic reseni {len(reseni)} ({reseni})') 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) resnode = ReseniNode(reseni=reseni)
poskladej_strom(apps, resnode, cl.text_zadani, cl.text_reseni) poskladej_strom(apps, resnode, cl.text_zadani, cl.text_reseni)
resnode.save() resnode.save()
reseni.text_cely = resnode
reseni.save()
def fix_Clanek_Reseni(apps, schema_editor): def fix_Clanek_Reseni(apps, schema_editor):
Problem = apps.get_model('seminar', 'Problem') Problem = apps.get_model('seminar', 'Problem')

8
seminar/migrations/0060_spoj_stromy.py

@ -85,8 +85,12 @@ def pokacej_les(apps, schema_editor):
# Články # Články
for cl in Clanek.objects.filter(cislo = c).order_by('kod'): for cl in Clanek.objects.filter(cislo = c).order_by('kod'):
clnode = cl.claneknode # Zmena: Clanky nemaji vlastni Node, ale pouziva se ReseniNode v text_cely
pridej_potomka(cnode, clnode) 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 # Konfery
for k in Konfera.objects.all(): for k in Konfera.objects.all():

Loading…
Cancel
Save