|
|
@ -4,12 +4,19 @@ from __future__ import unicode_literals |
|
|
|
|
|
|
|
from django.db import migrations |
|
|
|
|
|
|
|
def oprav_pohadku(apps, schema_editor): |
|
|
|
def vytvor_pohadkanode(apps, schema_editor): |
|
|
|
Pohadka = apps.get_model('seminar', 'Pohadka') |
|
|
|
PohadkaNode = apps.get_model('seminar', 'PohadkaNode') |
|
|
|
Text = apps.get_model('seminar', 'Text') |
|
|
|
TextNode = apps.get_model('seminar', 'TextNode') |
|
|
|
|
|
|
|
for p in Pohadka.objects.all(): |
|
|
|
if p.uloha_old: |
|
|
|
p.uloha = p.uloha_old.uloha # Pokud to nebyla úloha, vyhodí Uloha.DoesNotExists výjimku. |
|
|
|
t = Text.objects.create(na_web = p.text) |
|
|
|
t.save() |
|
|
|
tn = TextNode.objects.create(text = t) |
|
|
|
tn.save() |
|
|
|
pn = PohadkaNode.create(pohadka = p, first_child = tn) |
|
|
|
pn.save() |
|
|
|
|
|
|
|
class Migration(migrations.Migration): |
|
|
|
|
|
|
@ -18,5 +25,5 @@ class Migration(migrations.Migration): |
|
|
|
] |
|
|
|
|
|
|
|
operations = [ |
|
|
|
migrations.RunPython(oprav_pohadku), |
|
|
|
migrations.RunPython(vytvor_pohadkanode), |
|
|
|
] |
|
|
|