You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# Generated by Django 1.11.20 on 2019-05-23 21:54
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
def generuj_RocnikNody_a_CisloNody(apps,schema_editor):
|
|
|
|
Rocnik = apps.get_model('seminar', 'Rocnik')
|
|
|
|
RocnikNode = apps.get_model('seminar', 'RocnikNode')
|
|
|
|
Cislo = apps.get_model('seminar', 'Cislo')
|
|
|
|
CisloNode = apps.get_model('seminar', 'CisloNode')
|
|
|
|
|
|
|
|
last_rn = None # last_* slouží k navázání následníků
|
|
|
|
for r in Rocnik.objects.all():
|
|
|
|
rn = RocnikNode.objects.create(rocnik=r)
|
|
|
|
rn.save()
|
|
|
|
rn.root = rn
|
|
|
|
rn.save()
|
|
|
|
if last_rn:
|
|
|
|
last_rn.succ = rn
|
|
|
|
last_rn.save()
|
|
|
|
last_rn = rn
|
|
|
|
|
|
|
|
last_cn = None
|
|
|
|
for c in Cislo.objects.filter(rocnik=r):
|
|
|
|
cn = CisloNode.objects.create(cislo=c, root=rn)
|
|
|
|
cn.save()
|
|
|
|
if last_cn: # Jsme něčí následník
|
|
|
|
last_cn.succ = cn
|
|
|
|
last_cn.save()
|
|
|
|
else: # Jsme první v řadě, takže se musíme přidat jako first_child RočníkNodu
|
|
|
|
rn.first_child = cn
|
|
|
|
rn.save()
|
|
|
|
last_cn = cn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
('seminar', '0055_smazat_nemigrovane_zastarale_veci'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(generuj_RocnikNody_a_CisloNody, migrations.RunPython.noop),
|
|
|
|
]
|