diff --git a/seminar/migrations/0050_auto_20190510_2228.py b/seminar/migrations/0050_auto_20190510_2228.py new file mode 100644 index 00000000..4226380a --- /dev/null +++ b/seminar/migrations/0050_auto_20190510_2228.py @@ -0,0 +1,178 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-05-10 20:28 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0049_auto_20190430_2354'), + ] + + 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( + model_name='konfera', + name='reseni', + field=models.OneToOneField(blank=True, help_text='Účastnický přípěvek o konfeře', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='konfery', to='seminar.Reseni', verbose_name='článek ke konfeře'), + ), + migrations.AlterField( + model_name='organizator', + name='osoba', + field=models.OneToOneField(help_text='osobní údaje organizátora', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='org', to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.AlterField( + model_name='reseni', + name='text_cely', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reseni_cely_set', to='seminar.Text', verbose_name='Plná verze textu řešení'), + ), + migrations.AlterField( + model_name='resitel', + name='osoba', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.AlterField( + model_name='uloha', + name='vzorak', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='uloha_vzorak_set', to='seminar.Text', verbose_name='vzorové řešení'), + ), + migrations.AlterField( + model_name='uloha', + 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í'), + ), + migrations.AddField( + model_name='cislonode', + name='cislo', + field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='číslo'), + ), + migrations.AddField( + model_name='cislonode', + 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'), + ), + migrations.AddField( + model_name='cislonode', + 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'), + ), + migrations.AddField( + model_name='cislonode', + 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'), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index 99caf07e..0ac920bc 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -217,7 +217,7 @@ class Resitel(SeminarModelBase): # Interní ID id = models.AutoField(primary_key = True) - osoba = models.ForeignKey(Osoba, blank=False, null=True, verbose_name='osoba') # FIXME opravit po prvni migraci + osoba = models.OneToOneField(Osoba, blank=False, null=True, verbose_name='osoba') # FIXME opravit po prvni migraci skola = models.ForeignKey(Skola, blank=True, null=True, verbose_name='škola') @@ -455,7 +455,7 @@ class Cislo(SeminarModelBase): class Organizator(SeminarModelBase): # zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu - osoba = models.ForeignKey(Osoba, verbose_name='osoba', related_name='org', + osoba = models.OneToOneField(Osoba, verbose_name='osoba', related_name='org', help_text='osobní údaje organizátora', null=True, blank=False) #FIXME opravit po migraci vytvoreno = models.DateTimeField( @@ -709,9 +709,9 @@ class Uloha(Problem): verbose_name_plural = 'Úlohy' - zadani = models.ForeignKey(Text, verbose_name='veřejné zadání', related_name="uloha_zadani_set", blank=True, null=True) + zadani = models.OneToOneField(Text, verbose_name='veřejné zadání', related_name="uloha_zadani_set", blank=True, null=True) - vzorak = models.ForeignKey(Text, verbose_name='vzorové řešení', related_name="uloha_vzorak_set", blank=True, null=True) + vzorak = models.OneToOneField(Text, verbose_name='vzorové řešení', related_name="uloha_vzorak_set", blank=True, null=True) cislo_zadani = models.ForeignKey(Cislo, verbose_name='číslo zadání', blank=True, null=True, related_name='zadane_ulohy') @@ -768,7 +768,7 @@ class Reseni(SeminarModelBase): forma = models.CharField('forma řešení', max_length=16, choices=FORMA_CHOICES, blank=False, default=FORMA_EMAIL) - text_cely = models.ForeignKey(Text, verbose_name='Plná verze textu řešení', + text_cely = models.OneToOneField(Text, verbose_name='Plná verze textu řešení', blank=True, null=True, related_name="reseni_cely_set") text_zkraceny = models.ManyToManyField(Text, verbose_name='zkrácené verze řešení', @@ -998,8 +998,8 @@ class Konfera(models.Model): poznamka = models.TextField('neveřejná poznámka', blank=True, help_text='Neveřejná poznámka ke konfeře(plain text)') - - reseni = models.ForeignKey(Reseni, verbose_name='článek ke konfeře', related_name='konfery', + # Jedno reseni se vztahuje nejvyse k jedne konfere + reseni = models.OneToOneField(Reseni, verbose_name='článek ke konfeře', related_name='konfery', help_text='Účastnický přípěvek o konfeře', on_delete = models.SET_NULL, null=True, blank=True) @@ -1106,7 +1106,7 @@ class TreeNode(models.Model): blank = True, on_delete=models.SET_NULL, verbose_name="první potomek") - succ = models.ForeignKey('self', + succ = models.OneToOneField('self', related_name="prev", null = True, blank = True, @@ -1118,7 +1118,7 @@ class RocnikNode(TreeNode): db_table = 'seminar_nodes_rocnik' verbose_name = 'Ročník (Node)' verbose_name_plural = 'Ročníky (Node)' - rocnik = models.ForeignKey(Rocnik, + rocnik = models.OneToOneField(Rocnik, on_delete = models.PROTECT, # Pokud chci mazat ročník, musím si Node pořešit ručně verbose_name = "ročník") @@ -1127,7 +1127,7 @@ class CisloNode(TreeNode): db_table = 'seminar_nodes_cislo' verbose_name = 'Číslo (Node)' verbose_name_plural = 'Čísla (Node)' - cislo = models.ForeignKey(Cislo, + cislo = models.OneToOneField(Cislo, on_delete = models.PROTECT, # Pokud chci mazat číslo, musím si Node pořešit ručně verbose_name = "číslo")