Opravy migraci. Potreba projit a opravit semantiku.
This commit is contained in:
parent
fbd203c2b2
commit
f89e696fe3
5 changed files with 34 additions and 31 deletions
|
@ -61,7 +61,7 @@ class Migration(migrations.Migration):
|
|||
name='ClanekNode',
|
||||
fields=[
|
||||
('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')),
|
||||
('clanek', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Clanek', verbose_name='článek')),
|
||||
('clanek', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Clanek', verbose_name='článek')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Článek (Node)',
|
||||
|
@ -74,7 +74,7 @@ class Migration(migrations.Migration):
|
|||
name='KonferaNode',
|
||||
fields=[
|
||||
('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')),
|
||||
('konfera', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Konfera', verbose_name='konfera')),
|
||||
('konfera', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Konfera', verbose_name='konfera')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Konfera (Node)',
|
||||
|
@ -138,7 +138,7 @@ class Migration(migrations.Migration):
|
|||
name='UlohaVzorakNode',
|
||||
fields=[
|
||||
('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')),
|
||||
('uloha', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')),
|
||||
('uloha', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Vzorák úlohy (Node)',
|
||||
|
@ -151,7 +151,7 @@ class Migration(migrations.Migration):
|
|||
name='UlohaZadaniNode',
|
||||
fields=[
|
||||
('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')),
|
||||
('uloha', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')),
|
||||
('uloha', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Zadání úlohy (Node)',
|
||||
|
|
|
@ -43,7 +43,7 @@ def uloha_to_Uloha(apps,schema_editor):
|
|||
ulohy = Problem.objects.filter(typ = 'uloha')
|
||||
for uold in ulohy:
|
||||
unew = Uloha.objects.create(
|
||||
problem = uold,
|
||||
problem_ptr = uold,
|
||||
# Zakomentované fieldy by se už měly nacházet v příslušném problému
|
||||
#nazev = uold.nazev,
|
||||
#stav = uold.stav,
|
||||
|
@ -84,17 +84,18 @@ def clanek_to_Clanek(apps,schema_editor):
|
|||
clanky = Problem.objects.filter(Q(typ='org-clanek') | Q(typ='res-clanek'))
|
||||
for cl in clanky:
|
||||
# Vybereme vhodné číslo pro článek z čísla zadání a čísla řešení:
|
||||
if cl.cislo_zadani is None:
|
||||
cislo = cl.cislo_reseni
|
||||
elif cl.cislo_reseni is None:
|
||||
cislo = cl.cislo_zadani
|
||||
elif cl.cislo_reseni == cl.cislo_zadani:
|
||||
cislo = cl.cislo_zadani
|
||||
if cl.cislo_zadani_old is None:
|
||||
cislo = cl.cislo_reseni_old
|
||||
elif cl.cislo_reseni_old is None:
|
||||
cislo = cl.cislo_zadani_old
|
||||
elif cl.cislo_reseni_old == cl.cislo_zadani_old:
|
||||
cislo = cl.cislo_zadani_old
|
||||
else:
|
||||
raise ValueError("Různá čísla zadání a řešení u článku!")
|
||||
cislo = cl.cislo_zadani_old
|
||||
#raise ValueError("Různá čísla zadání a řešení u článku!")
|
||||
|
||||
clnew = Clanek.objects.create(
|
||||
problem = cl,
|
||||
problem_ptr = cl,
|
||||
# Problém by nemělo být potřeba upravovat
|
||||
cislo = cislo,
|
||||
# Body ignorujeme, protože už jsou v hodnocení
|
||||
|
@ -122,17 +123,19 @@ def tema_to_Tema(apps, schema_editor):
|
|||
temata = Problem.objects.filter(Q(typ = 'tema') | Q(typ='serial'))
|
||||
for t in temata:
|
||||
# Vymyslíme správně ročník:
|
||||
if t.cislo_zadani is None:
|
||||
rocnik = t.cislo_reseni.rocnik
|
||||
elif t.cislo_reseni is None:
|
||||
rocnik = t.cislo_zadani.rocnik
|
||||
elif t.cislo_reseni.rocnik == t.cislo_zadani.rocnik:
|
||||
rocnik = t.cislo_zadani.rocnik
|
||||
if t.cislo_zadani_old is None and t.cislo_reseni_old is None:
|
||||
rocnik = None
|
||||
elif t.cislo_zadani_old is None:
|
||||
rocnik = t.cislo_reseni_old.rocnik
|
||||
elif t.cislo_reseni_old is None:
|
||||
rocnik = t.cislo_zadani_old.rocnik
|
||||
elif t.cislo_reseni_old.rocnik == t.cislo_zadani_old.rocnik:
|
||||
rocnik = t.cislo_zadani_old.rocnik
|
||||
else:
|
||||
raise ValueError("Nelze mít téma přes více ročníků!")
|
||||
|
||||
tnew = Tema.objects.create(
|
||||
problem = t,
|
||||
problem_ptr = t,
|
||||
tema_typ = t.typ,
|
||||
rocnik = rocnik,
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ def vytvor_pohadkanode(apps, schema_editor):
|
|||
t.save()
|
||||
tn = TextNode.objects.create(text = t)
|
||||
tn.save()
|
||||
pn = PohadkaNode.create(pohadka = p, first_child = tn)
|
||||
pn = PohadkaNode.objects.create(pohadka = p, first_child = tn)
|
||||
pn.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -53,13 +53,13 @@ def pokacej_les(apps, schema_editor):
|
|||
cnode = c.cislonode
|
||||
|
||||
# Témata a seriály:
|
||||
relevantni_temata = Tema.objects.filter(Q(cislo_zadani = c) | Q(cislo_reseni = c)).order_by('kod')
|
||||
relevantni_temata = Tema.objects.filter(Q(cislo_zadani_old = c) | Q(cislo_reseni_old = c)).order_by('kod')
|
||||
# Téma dáme do prvního čísla, kde se vyskytne
|
||||
for t in relevantni_temata:
|
||||
tnode = t.temavcislenode
|
||||
if t.cislo_zadani and t.cislo_reseni:
|
||||
assert(t.cislo_zadani <= t.cislo_reseni)
|
||||
if t.cislo_reseni == c:
|
||||
if t.cislo_zadani_old and t.cislo_reseni_old:
|
||||
assert(t.cislo_zadani_old <= t.cislo_reseni_old)
|
||||
if t.cislo_reseni_old == c:
|
||||
# Už by mělo být přidané do čísla zadání
|
||||
continue
|
||||
else:
|
||||
|
@ -69,8 +69,8 @@ def pokacej_les(apps, schema_editor):
|
|||
# Úložky (zadání) a pohádky
|
||||
for u in Uloha.objects.filter(cislo_zadani = c).order_by('kod'):
|
||||
unode = u.ulohazadaninode
|
||||
pohadky_pred = Pohadka.objects.filter(uloha_old = u.problem, pred = True)
|
||||
pohadky_po = Pohadka.objects.filter(uloha_old = u.problem, pred = False)
|
||||
pohadky_pred = Pohadka.objects.filter(uloha_old = u.problem_ptr, pred = True)
|
||||
pohadky_po = Pohadka.objects.filter(uloha_old = u.problem_ptr, pred = False)
|
||||
for p in pohadky_pred:
|
||||
pnode = p.pohadkanode
|
||||
pridej_potomka(cnode, pnode)
|
||||
|
|
|
@ -1138,7 +1138,7 @@ class KonferaNode(TreeNode):
|
|||
db_table = 'seminar_nodes_konfera'
|
||||
verbose_name = 'Konfera (Node)'
|
||||
verbose_name_plural = 'Konfery (Node)'
|
||||
konfera = models.ForeignKey(Konfera,
|
||||
konfera = models.OneToOneField(Konfera,
|
||||
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||
verbose_name = "konfera",
|
||||
null=True,
|
||||
|
@ -1149,7 +1149,7 @@ class ClanekNode(TreeNode):
|
|||
db_table = 'seminar_nodes_clanek'
|
||||
verbose_name = 'Článek (Node)'
|
||||
verbose_name_plural = 'Články (Node)'
|
||||
clanek = models.ForeignKey(Clanek,
|
||||
clanek = models.OneToOneField(Clanek,
|
||||
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||
verbose_name = "článek",
|
||||
null=True,
|
||||
|
@ -1160,7 +1160,7 @@ class UlohaZadaniNode(TreeNode):
|
|||
db_table = 'seminar_nodes_uloha_zadani'
|
||||
verbose_name = 'Zadání úlohy (Node)'
|
||||
verbose_name_plural = 'Zadání úloh (Node)'
|
||||
uloha = models.ForeignKey(Uloha,
|
||||
uloha = models.OneToOneField(Uloha,
|
||||
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||
verbose_name = "úloha",
|
||||
null=True,
|
||||
|
@ -1181,7 +1181,7 @@ class UlohaVzorakNode(TreeNode):
|
|||
db_table = 'seminar_nodes_uloha_vzorak'
|
||||
verbose_name = 'Vzorák úlohy (Node)'
|
||||
verbose_name_plural = 'Vzoráky úloh (Node)'
|
||||
uloha = models.ForeignKey(Uloha,
|
||||
uloha = models.OneToOneField(Uloha,
|
||||
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||
verbose_name = "úloha",
|
||||
null=True,
|
||||
|
|
Loading…
Reference in a new issue