|
|
@ -78,7 +78,7 @@ def konfery_rucne(apps, schema_editor): |
|
|
|
def clanek_to_Clanek(apps,schema_editor): |
|
|
|
Problem = apps.get_model('seminar', 'Problem') |
|
|
|
Clanek = apps.get_model('seminar', 'Clanek') |
|
|
|
ClanekNode = apps.get_model('seminar', 'ClanekNode') |
|
|
|
ReseniNode = apps.get_model('seminar', 'ReseniNode') |
|
|
|
Text = apps.get_model('seminar', 'Text') |
|
|
|
TextNode = apps.get_model('seminar', 'TextNode') |
|
|
|
|
|
|
@ -105,10 +105,23 @@ def clanek_to_Clanek(apps,schema_editor): |
|
|
|
|
|
|
|
cl.save() |
|
|
|
|
|
|
|
|
|
|
|
def Clanek_Treenody(apps, schema_editor): |
|
|
|
Problem = apps.get_model('seminar', 'Problem') |
|
|
|
Clanek = apps.get_model('seminar', 'Clanek') |
|
|
|
ReseniNode = apps.get_model('seminar', 'ReseniNode') |
|
|
|
Text = apps.get_model('seminar', 'Text') |
|
|
|
TextNode = apps.get_model('seminar', 'TextNode') |
|
|
|
for cl in Clanek.objects.all(): |
|
|
|
# Vyrobíme nody: |
|
|
|
clnode = ClanekNode(clanek = clnew) |
|
|
|
poskladej_strom(apps, clnode, cl.text_zadani, cl.text_reseni) |
|
|
|
clnode.save() |
|
|
|
# Clanek nema vlastni node, ma (prave jedno) Reseni a to ma ReseniNode |
|
|
|
reseni = cl.reseni_set.all() |
|
|
|
if len(reseni) != 1: |
|
|
|
raise ValueError(f'Clanek {cl.id} ma vic reseni {len(reseni)} ({reseni})') |
|
|
|
reseni = reseni[0] |
|
|
|
resnode = ReseniNode(reseni=reseni) |
|
|
|
poskladej_strom(apps, resnode, cl.text_zadani, cl.text_reseni) |
|
|
|
resnode.save() |
|
|
|
|
|
|
|
def fix_Clanek_Reseni(apps, schema_editor): |
|
|
|
Problem = apps.get_model('seminar', 'Problem') |
|
|
@ -139,11 +152,9 @@ def fix_Clanek_Reseni(apps, schema_editor): |
|
|
|
if h.id != vzor_hodnoceni.id: |
|
|
|
ostatni_hodnoceni.append(h) |
|
|
|
resitele.extend(r.resitele.all()) |
|
|
|
print(f'*** cl={cl.id}, res={resitele}') |
|
|
|
rr[0].resitele.set(resitele) |
|
|
|
rr[0].save() |
|
|
|
vzor_hodnoceni.save() |
|
|
|
print(f'vzor = {vzor_hodnoceni}, ostatni = {ostatni_hodnoceni}') |
|
|
|
# Ted mame spravne databazi, jeste potrebujeme z databaze smazat po novu nepouzita hodnoceni |
|
|
|
for h in ostatni_hodnoceni: |
|
|
|
h.reseni.delete() |
|
|
@ -195,5 +206,6 @@ class Migration(migrations.Migration): |
|
|
|
migrations.RunPython(tema_to_Tema, migrations.RunPython.noop), |
|
|
|
migrations.RunPython(clanek_to_Clanek, migrations.RunPython.noop), |
|
|
|
migrations.RunPython(fix_Clanek_Reseni, migrations.RunPython.noop), |
|
|
|
migrations.RunPython(Clanek_Treenody, migrations.RunPython.noop), |
|
|
|
migrations.RunPython(konfery_rucne, migrations.RunPython.noop), |
|
|
|
] |
|
|
|