Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
commit
b0e2bb9dfc
5 changed files with 253 additions and 133 deletions
BIN
Schema_new.dia
BIN
Schema_new.dia
Binary file not shown.
|
@ -13,118 +13,6 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
|
||||||
name='CisloNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Číslo (Node)',
|
|
||||||
'verbose_name_plural': 'Čísla (Node)',
|
|
||||||
'db_table': 'seminar_nodes_cislo',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='ClanekNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.ClanekNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.ClanekNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.ClanekNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Článek (Node)',
|
|
||||||
'verbose_name_plural': 'Články (Node)',
|
|
||||||
'db_table': 'seminar_nodes_clanek',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='KonferaNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.KonferaNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.KonferaNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.KonferaNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Konfera (Node)',
|
|
||||||
'verbose_name_plural': 'Konfery (Node)',
|
|
||||||
'db_table': 'seminar_nodes_konfera',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='MezicisloNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.MezicisloNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.MezicisloNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.MezicisloNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Mezičíslo (Node)',
|
|
||||||
'verbose_name_plural': 'Mezičísla (Node)',
|
|
||||||
'db_table': 'seminar_nodes_mezicislo',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='RocnikNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.RocnikNode', verbose_name='první potomek')),
|
|
||||||
('rocnik', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Rocnik', verbose_name='ročník')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.RocnikNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.RocnikNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Ročník (Node)',
|
|
||||||
'verbose_name_plural': 'Ročníky (Node)',
|
|
||||||
'db_table': 'seminar_nodes_rocnik',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='TemaVCisleNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.TemaVCisleNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.TemaVCisleNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.TemaVCisleNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
('tema', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Tema', verbose_name='téma v čísle')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Téma v čísle (Node)',
|
|
||||||
'verbose_name_plural': 'Témata v čísle (Node)',
|
|
||||||
'db_table': 'seminar_nodes_temavcisle',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='TextNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.TextNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.TextNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.TextNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
('text', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Text', verbose_name='text')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Text (Node)',
|
|
||||||
'verbose_name_plural': 'Text (Node)',
|
|
||||||
'db_table': 'seminar_nodes_obsah',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='UlohaNode',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.UlohaNode', verbose_name='první potomek')),
|
|
||||||
('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.UlohaNode', verbose_name='kořen stromu')),
|
|
||||||
('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.UlohaNode', verbose_name='další element na stejné úrovni')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'Úloha (Node)',
|
|
||||||
'verbose_name_plural': 'Úlohy (Node)',
|
|
||||||
'db_table': 'seminar_nodes_uloha',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='konfera',
|
model_name='konfera',
|
||||||
name='reseni',
|
name='reseni',
|
||||||
|
@ -155,24 +43,146 @@ class Migration(migrations.Migration):
|
||||||
name='zadani',
|
name='zadani',
|
||||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='uloha_zadani_set', to='seminar.Text', verbose_name='veřejné zadání'),
|
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='uloha_zadani_set', to='seminar.Text', verbose_name='veřejné zadání'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.CreateModel(
|
||||||
model_name='cislonode',
|
name='TreeNode',
|
||||||
name='cislo',
|
fields=[
|
||||||
field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='číslo'),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'TreeNode',
|
||||||
|
'verbose_name_plural': 'TreeNody',
|
||||||
|
'db_table': 'seminar_nodes_treenode',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CisloNode',
|
||||||
|
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')),
|
||||||
|
('cislo', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='číslo')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Číslo (Node)',
|
||||||
|
'verbose_name_plural': 'Čísla (Node)',
|
||||||
|
'db_table': 'seminar_nodes_cislo',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
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')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Článek (Node)',
|
||||||
|
'verbose_name_plural': 'Články (Node)',
|
||||||
|
'db_table': 'seminar_nodes_clanek',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
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')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Konfera (Node)',
|
||||||
|
'verbose_name_plural': 'Konfery (Node)',
|
||||||
|
'db_table': 'seminar_nodes_konfera',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MezicisloNode',
|
||||||
|
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')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Mezičíslo (Node)',
|
||||||
|
'verbose_name_plural': 'Mezičísla (Node)',
|
||||||
|
'db_table': 'seminar_nodes_mezicislo',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='RocnikNode',
|
||||||
|
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')),
|
||||||
|
('rocnik', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Rocnik', verbose_name='ročník')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ročník (Node)',
|
||||||
|
'verbose_name_plural': 'Ročníky (Node)',
|
||||||
|
'db_table': 'seminar_nodes_rocnik',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TemaVCisleNode',
|
||||||
|
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')),
|
||||||
|
('tema', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Tema', verbose_name='téma v čísle')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Téma v čísle (Node)',
|
||||||
|
'verbose_name_plural': 'Témata v čísle (Node)',
|
||||||
|
'db_table': 'seminar_nodes_temavcisle',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TextNode',
|
||||||
|
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')),
|
||||||
|
('text', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Text', verbose_name='text')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Text (Node)',
|
||||||
|
'verbose_name_plural': 'Text (Node)',
|
||||||
|
'db_table': 'seminar_nodes_obsah',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
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')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Vzorák úlohy (Node)',
|
||||||
|
'verbose_name_plural': 'Vzoráky úloh (Node)',
|
||||||
|
'db_table': 'seminar_nodes_uloha_vzorak',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
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')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Zadání úlohy (Node)',
|
||||||
|
'verbose_name_plural': 'Zadání úloh (Node)',
|
||||||
|
'db_table': 'seminar_nodes_uloha_zadani',
|
||||||
|
},
|
||||||
|
bases=('seminar.treenode',),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='cislonode',
|
model_name='treenode',
|
||||||
name='first_child',
|
name='first_child',
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.CisloNode', verbose_name='první potomek'),
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.TreeNode', verbose_name='první potomek'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='cislonode',
|
model_name='treenode',
|
||||||
name='root',
|
name='root',
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.CisloNode', verbose_name='kořen stromu'),
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.TreeNode', verbose_name='kořen stromu'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='cislonode',
|
model_name='treenode',
|
||||||
name='succ',
|
name='succ',
|
||||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.CisloNode', verbose_name='další element na stejné úrovni'),
|
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.TreeNode', verbose_name='další element na stejné úrovni'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
47
seminar/migrations/0056_vrcholy_pro_rocniky_a_cisla.py
Normal file
47
seminar/migrations/0056_vrcholy_pro_rocniky_a_cisla.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# 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),
|
||||||
|
]
|
|
@ -1093,19 +1093,22 @@ class Obrazek(SeminarModelBase):
|
||||||
|
|
||||||
class TreeNode(models.Model):
|
class TreeNode(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
db_table = "seminar_nodes_treenode"
|
||||||
root = models.ForeignKey('self',
|
verbose_name = "TreeNode"
|
||||||
|
verbose_name_plural = "TreeNody"
|
||||||
|
|
||||||
|
root = models.ForeignKey('TreeNode',
|
||||||
related_name="potomci_set",
|
related_name="potomci_set",
|
||||||
null = True,
|
null = True,
|
||||||
blank = False,
|
blank = False,
|
||||||
on_delete = models.SET_NULL, # Vrcholy s null kořenem jsou sirotci bez ročníku
|
on_delete = models.SET_NULL, # Vrcholy s null kořenem jsou sirotci bez ročníku
|
||||||
verbose_name="kořen stromu")
|
verbose_name="kořen stromu")
|
||||||
first_child = models.ForeignKey('self',
|
first_child = models.ForeignKey('TreeNode',
|
||||||
null = True,
|
null = True,
|
||||||
blank = True,
|
blank = True,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
verbose_name="první potomek")
|
verbose_name="první potomek")
|
||||||
succ = models.OneToOneField('self',
|
succ = models.OneToOneField('TreeNode',
|
||||||
related_name="prev",
|
related_name="prev",
|
||||||
null = True,
|
null = True,
|
||||||
blank = True,
|
blank = True,
|
||||||
|
@ -1151,18 +1154,44 @@ class KonferaNode(TreeNode):
|
||||||
db_table = 'seminar_nodes_konfera'
|
db_table = 'seminar_nodes_konfera'
|
||||||
verbose_name = 'Konfera (Node)'
|
verbose_name = 'Konfera (Node)'
|
||||||
verbose_name_plural = 'Konfery (Node)'
|
verbose_name_plural = 'Konfery (Node)'
|
||||||
|
konfera = models.ForeignKey(Konfera,
|
||||||
|
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||||
|
verbose_name = "konfera",
|
||||||
|
null=True,
|
||||||
|
blank=False)
|
||||||
|
|
||||||
class ClanekNode(TreeNode):
|
class ClanekNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_nodes_clanek'
|
db_table = 'seminar_nodes_clanek'
|
||||||
verbose_name = 'Článek (Node)'
|
verbose_name = 'Článek (Node)'
|
||||||
verbose_name_plural = 'Články (Node)'
|
verbose_name_plural = 'Články (Node)'
|
||||||
|
clanek = models.ForeignKey(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,
|
||||||
|
blank=False)
|
||||||
|
|
||||||
class UlohaNode(TreeNode):
|
class UlohaZadaniNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_nodes_uloha'
|
db_table = 'seminar_nodes_uloha_zadani'
|
||||||
verbose_name = 'Úloha (Node)'
|
verbose_name = 'Zadání úlohy (Node)'
|
||||||
verbose_name_plural = 'Úlohy (Node)'
|
verbose_name_plural = 'Zadání úloh (Node)'
|
||||||
|
uloha = models.ForeignKey(Uloha,
|
||||||
|
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||||
|
verbose_name = "úloha",
|
||||||
|
null=True,
|
||||||
|
blank=False)
|
||||||
|
|
||||||
|
class UlohaVzorakNode(TreeNode):
|
||||||
|
class Meta:
|
||||||
|
db_table = 'seminar_nodes_uloha_vzorak'
|
||||||
|
verbose_name = 'Vzorák úlohy (Node)'
|
||||||
|
verbose_name_plural = 'Vzoráky úloh (Node)'
|
||||||
|
uloha = models.ForeignKey(Uloha,
|
||||||
|
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||||
|
verbose_name = "úloha",
|
||||||
|
null=True,
|
||||||
|
blank=False)
|
||||||
|
|
||||||
class TextNode(TreeNode):
|
class TextNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -125,6 +125,10 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
||||||
'''
|
'''
|
||||||
cislo = cislo cisla v rocniku, nikoli objekt Cislo
|
cislo = cislo cisla v rocniku, nikoli objekt Cislo
|
||||||
'''
|
'''
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> 69f9b54e7b5dbb36070d978d29d90987b1c9212b
|
||||||
# ulohy resene v ci
|
# ulohy resene v ci
|
||||||
jaka = ["Šachová", "Černá", "Větrná", "Dlouhá", "Křehká", "Rychlá",
|
jaka = ["Šachová", "Černá", "Větrná", "Dlouhá", "Křehká", "Rychlá",
|
||||||
"Zákeřná", "Fyzikální"]
|
"Zákeřná", "Fyzikální"]
|
||||||
|
@ -160,11 +164,24 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
||||||
cislo_zadani=slovnik_cisel[cislo-2],
|
cislo_zadani=slovnik_cisel[cislo-2],
|
||||||
cislo_reseni=slovnik_cisel[cislo],
|
cislo_reseni=slovnik_cisel[cislo],
|
||||||
cislo_deadline=slovnik_cisel[cislo],
|
cislo_deadline=slovnik_cisel[cislo],
|
||||||
|
<<<<<<< HEAD
|
||||||
max_body = rnd.randint(1, 8))
|
max_body = rnd.randint(1, 8))
|
||||||
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho),
|
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho),
|
||||||
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)])
|
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)])
|
||||||
p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)])
|
p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)])
|
||||||
p.opravovatele = rnd.sample(organizatori, poc_op)
|
p.opravovatele = rnd.sample(organizatori, poc_op)
|
||||||
|
=======
|
||||||
|
max_body = rnd.randint(1, 8)
|
||||||
|
)
|
||||||
|
p.zadani = " ".join(
|
||||||
|
[rnd.choice(sloveso),
|
||||||
|
rnd.choice(koho),
|
||||||
|
rnd.choice(ceho),
|
||||||
|
rnd.choice(jmeno),
|
||||||
|
rnd.choice(kde)]
|
||||||
|
)
|
||||||
|
p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)])
|
||||||
|
>>>>>>> 69f9b54e7b5dbb36070d978d29d90987b1c9212b
|
||||||
p.save()
|
p.save()
|
||||||
|
|
||||||
# reseni ulohy
|
# reseni ulohy
|
||||||
|
@ -174,6 +191,7 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
||||||
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni)
|
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni)
|
||||||
res_vyber = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2))
|
res_vyber = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2))
|
||||||
for resitel in res_vyber:
|
for resitel in res_vyber:
|
||||||
|
<<<<<<< HEAD
|
||||||
# problem a resitele přiřadíme později, ManyToManyField
|
# problem a resitele přiřadíme později, ManyToManyField
|
||||||
# se nedá vyplnit v create()
|
# se nedá vyplnit v create()
|
||||||
res = Reseni.objects.create(forma=rnd.choice(Reseni.FORMA_CHOICES))
|
res = Reseni.objects.create(forma=rnd.choice(Reseni.FORMA_CHOICES))
|
||||||
|
@ -184,15 +202,31 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
||||||
body=rnd.randint(0, p.max_body),
|
body=rnd.randint(0, p.max_body),
|
||||||
cislo_body=slovnik_cisel[cislo],
|
cislo_body=slovnik_cisel[cislo],
|
||||||
reseni=res, problem=p)
|
reseni=res, problem=p)
|
||||||
|
=======
|
||||||
|
res = Reseni.objects.create(
|
||||||
|
problem = p,
|
||||||
|
resitele=[resitel],
|
||||||
|
forma=rnd.choice(Reseni.FORMA_CHOICES)
|
||||||
|
)
|
||||||
|
hod = Hodnoceni.objects.create(
|
||||||
|
body=rnd.randint(0, p.max_body),
|
||||||
|
cislo_body=slovnik_cisel[cislo],
|
||||||
|
reseni=res,
|
||||||
|
problem=p
|
||||||
|
)
|
||||||
|
>>>>>>> 69f9b54e7b5dbb36070d978d29d90987b1c9212b
|
||||||
return
|
return
|
||||||
|
|
||||||
def gen_soustredeni():
|
def gen_soustredeni():
|
||||||
# TODO: vice soustredeni a k nim nahodne podmnoziny organizatoru a ucastniku
|
# TODO: vice soustredeni a k nim nahodne podmnoziny organizatoru a ucastniku
|
||||||
# TODO: pozor, organizatori a ucastnici jsou ManyToManyField, musí se přiřadit
|
# TODO: pozor, organizatori a ucastnici jsou ManyToManyField, musí se přiřadit
|
||||||
# mimo create() a pak dát save()
|
# mimo create() a pak dát save()
|
||||||
sous = Soustredeni.objects.create(rocnik=Rocnik.objects.first(), verejne_db=True,
|
sous = Soustredeni.objects.create(rocnik=Rocnik.objects.first(),
|
||||||
misto=u'Někde', datum_zacatku=datetime.date(2000, 11, 23),
|
verejne_db=True,
|
||||||
datum_konce=datetime.date(2000, 11, 27))
|
misto=u'Někde',
|
||||||
|
datum_zacatku=datetime.date(2000, 11, 23),
|
||||||
|
datum_konce=datetime.date(2000, 11, 27)
|
||||||
|
)
|
||||||
|
|
||||||
for res in rnd.sample(resitele, 6):
|
for res in rnd.sample(resitele, 6):
|
||||||
Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous)
|
Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous)
|
||||||
|
|
Loading…
Reference in a new issue