Spravnejsi vyrobeni treenodu pro clanek

This commit is contained in:
Pavel Turinsky (DebianVM @ Zr) 2021-06-22 22:29:11 +00:00
parent d66b8c3be2
commit d7898c39b1
2 changed files with 9 additions and 3 deletions

View file

@ -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')

View file

@ -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():