mamweb/seminar/migrations/0059_vytvorit_pohadkanode.py

30 lines
786 B
Python
Raw Normal View History

2019-05-29 17:42:54 +02:00
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-29 03:26
from __future__ import unicode_literals
from django.db import migrations
2019-05-30 01:37:15 +02:00
def vytvor_pohadkanode(apps, schema_editor):
2019-05-29 17:42:54 +02:00
Pohadka = apps.get_model('seminar', 'Pohadka')
2019-05-30 01:37:15 +02:00
PohadkaNode = apps.get_model('seminar', 'PohadkaNode')
Text = apps.get_model('seminar', 'Text')
TextNode = apps.get_model('seminar', 'TextNode')
2019-05-29 17:42:54 +02:00
for p in Pohadka.objects.all():
2019-05-30 01:37:15 +02:00
t = Text.objects.create(na_web = p.text)
t.save()
tn = TextNode.objects.create(text = t)
tn.save()
pn = PohadkaNode.objects.create(pohadka = p, first_child = tn)
2019-05-30 01:37:15 +02:00
pn.save()
2019-05-29 17:42:54 +02:00
class Migration(migrations.Migration):
dependencies = [
('seminar', '0058_problem_to_uloha_tema_clanek'),
2019-05-29 17:42:54 +02:00
]
operations = [
2019-05-30 01:37:15 +02:00
migrations.RunPython(vytvor_pohadkanode),
2019-05-29 17:42:54 +02:00
]