Přidána Pohádka do stromu
This commit is contained in:
parent
bbfb89b35d
commit
00d16bd25f
2 changed files with 19 additions and 12 deletions
|
@ -4,12 +4,19 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
def oprav_pohadku(apps, schema_editor):
|
def vytvor_pohadkanode(apps, schema_editor):
|
||||||
Pohadka = apps.get_model('seminar', 'Pohadka')
|
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():
|
for p in Pohadka.objects.all():
|
||||||
if p.uloha_old:
|
t = Text.objects.create(na_web = p.text)
|
||||||
p.uloha = p.uloha_old.uloha # Pokud to nebyla úloha, vyhodí Uloha.DoesNotExists výjimku.
|
t.save()
|
||||||
|
tn = TextNode.objects.create(text = t)
|
||||||
|
tn.save()
|
||||||
|
pn = PohadkaNode.create(pohadka = p, first_child = tn)
|
||||||
|
pn.save()
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
@ -18,5 +25,5 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(oprav_pohadku),
|
migrations.RunPython(vytvor_pohadkanode),
|
||||||
]
|
]
|
||||||
|
|
|
@ -72,16 +72,16 @@ def pokacej_les(apps, schema_editor):
|
||||||
pohadky_pred = Pohadka.objects.filter(uloha_old = u.problem, pred = True)
|
pohadky_pred = Pohadka.objects.filter(uloha_old = u.problem, pred = True)
|
||||||
pohadky_po = Pohadka.objects.filter(uloha_old = u.problem, pred = False)
|
pohadky_po = Pohadka.objects.filter(uloha_old = u.problem, pred = False)
|
||||||
for p in pohadky_pred:
|
for p in pohadky_pred:
|
||||||
# FIXME: Chceme pohádku do stromu?
|
pnode = p.pohadkanode
|
||||||
print('!!! !!! !!! !!! !!!')
|
pridej_potomka(cnode, pnode)
|
||||||
print('FIXME: Jak uložit pohádku??')
|
|
||||||
print('!!! !!! !!! !!! !!!')
|
|
||||||
pridej_potomka(cnode, unode)
|
pridej_potomka(cnode, unode)
|
||||||
for p in pohadky_po:
|
for p in pohadky_po:
|
||||||
# FIXME: Chceme pohádku do stromu?
|
pnode = p.pohadkanode
|
||||||
print('!!! !!! !!! !!! !!!')
|
pridej_potomka(cnode, pnode)
|
||||||
print('FIXME: Jak uložit pohádku??')
|
|
||||||
print('!!! !!! !!! !!! !!!')
|
# Pohádky, které nejsou u úlohy jsou špatně:
|
||||||
|
if Pohadka.objects.exclude(uloha_old__typ='uloha').count():
|
||||||
|
raise ValueError("Existuje pohádka, která není u úlohy")
|
||||||
|
|
||||||
# Články
|
# Články
|
||||||
for cl in Clanek.objects.filter(cislo = c).order_by('kod'):
|
for cl in Clanek.objects.filter(cislo = c).order_by('kod'):
|
||||||
|
|
Loading…
Reference in a new issue