diff --git a/seminar/migrations/0115_separace_tvorby.py b/seminar/migrations/0115_separace_tvorby.py new file mode 100644 index 00000000..50f99b55 --- /dev/null +++ b/seminar/migrations/0115_separace_tvorby.py @@ -0,0 +1,212 @@ +# Generated by Django 2.2.28 on 2023-08-09 15:15 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0114_separace_personalniho'), + ] + + operations = [ + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.RemoveField( + model_name='clanek', + name='cislo', + ), + migrations.RemoveField( + model_name='clanek', + name='problem_ptr', + ), + migrations.RemoveField( + model_name='deadline', + name='cislo', + ), + migrations.RemoveField( + model_name='pohadka', + name='autor', + ), + migrations.RemoveField( + model_name='problem', + name='autor', + ), + migrations.RemoveField( + model_name='problem', + name='garant', + ), + migrations.RemoveField( + model_name='problem', + name='nadproblem', + ), + migrations.RemoveField( + model_name='problem', + name='opravovatele', + ), + migrations.RemoveField( + model_name='problem', + name='polymorphic_ctype', + ), + migrations.RemoveField( + model_name='problem', + name='zamereni', + ), + migrations.RemoveField( + model_name='tema', + name='problem_ptr', + ), + migrations.RemoveField( + model_name='tema', + name='rocnik', + ), + migrations.RemoveField( + model_name='uloha', + name='cislo_deadline', + ), + migrations.RemoveField( + model_name='uloha', + name='cislo_reseni', + ), + migrations.RemoveField( + model_name='uloha', + name='cislo_zadani', + ), + migrations.RemoveField( + model_name='uloha', + name='problem_ptr', + ), + migrations.RemoveField( + model_name='zmrazenavysledkovka', + name='deadline', + ), + migrations.AlterField( + model_name='cislonode', + name='cislo', + field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='tvorba.Cislo', verbose_name='číslo'), + ), + migrations.AlterField( + model_name='hodnoceni', + name='cislo_body', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='tvorba.Cislo', verbose_name='číslo pro body'), + ), + migrations.AlterField( + model_name='hodnoceni', + name='deadline_body', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='tvorba.Deadline', verbose_name='deadline pro body'), + ), + migrations.AlterField( + model_name='hodnoceni', + name='problem', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='tvorba.Problem', verbose_name='problém'), + ), + migrations.AlterField( + model_name='konfera', + name='problem_ptr', + field=models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tvorba.Problem'), + ), + migrations.AlterField( + model_name='nastaveni', + name='aktualni_cislo', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='tvorba.Cislo', verbose_name='Aktuální číslo'), + ), + migrations.AlterField( + model_name='pohadkanode', + name='pohadka', + field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='tvorba.Pohadka', verbose_name='pohádka'), + ), + migrations.AlterField( + model_name='reseni', + name='problem', + field=models.ManyToManyField(help_text='Problém', through='seminar.Hodnoceni', to='tvorba.Problem', verbose_name='problém'), + ), + migrations.AlterField( + model_name='rocniknode', + name='rocnik', + field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='tvorba.Rocnik', verbose_name='ročník'), + ), + migrations.AlterField( + model_name='soustredeni', + name='rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='soustredeni', to='tvorba.Rocnik', verbose_name='ročník'), + ), + migrations.AlterField( + model_name='temavcislenode', + name='tema', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='tvorba.Tema', verbose_name='téma v čísle'), + ), + migrations.AlterField( + model_name='ulohavzoraknode', + name='uloha', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='tvorba.Uloha', verbose_name='úloha'), + ), + migrations.AlterField( + model_name='ulohazadaninode', + name='uloha', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='tvorba.Uloha', verbose_name='úloha'), + ), + ], + database_operations=[], + ), + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.DeleteModel( + name='Cislo', + ), + migrations.DeleteModel( + name='Clanek', + ), + migrations.DeleteModel( + name='Deadline', + ), + migrations.DeleteModel( + name='Pohadka', + ), + migrations.DeleteModel( + name='Problem', + ), + migrations.DeleteModel( + name='Rocnik', + ), + migrations.DeleteModel( + name='Tema', + ), + migrations.DeleteModel( + name='Uloha', + ), + migrations.DeleteModel( + name='ZmrazenaVysledkovka', + ), + ], + database_operations=[ + migrations.AlterModelTable( + name='Cislo', table="mam_cisla", + ), + migrations.AlterModelTable( + name='Deadline', table="mam_deadliny", + ), + migrations.AlterModelTable( + name='Problem', table="mam_problemy", + ), + migrations.AlterModelTable( + name='Rocnik', table="mam_rocniky", + ), + migrations.AlterModelTable( + name='ZmrazenaVysledkovka', table="mam_vysledkovky", + ), + migrations.AlterModelTable( + name='Pohadka', table="mam_pohadky", + ), + migrations.AlterModelTable( + name='Uloha', table="mam_ulohy", + ), + migrations.AlterModelTable( + name='Tema', table="mam_temata", + ), + migrations.AlterModelTable( + name='Clanek', table="mam_clanky", + ), + ], + ), + ] diff --git a/tvorba/migrations/0001_initial.py b/tvorba/migrations/0001_initial.py new file mode 100644 index 00000000..a54014c9 --- /dev/null +++ b/tvorba/migrations/0001_initial.py @@ -0,0 +1,177 @@ +# Generated by Django 2.2.28 on 2023-08-09 15:15 + +import datetime +from django.db import migrations, models +import django.db.models.deletion +from django.utils.timezone import utc +import django.utils.timezone +import taggit.managers +import tvorba.models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('taggit', '0004_alter_taggeditem_content_type_alter_taggeditem_tag'), + ('contenttypes', '0002_remove_content_type_name'), + ('personalni', '0002_organizator_osoba_prijemce_resitel_skola'), + ('seminar', '0114_separace_personalniho'), + ] + + operations = [ + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.CreateModel( + name='Cislo', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('poradi', models.CharField(db_index=True, help_text='Většinou jen "1", vyjímečně "7-8", lexikograficky určuje pořadí v ročníku!', max_length=32, verbose_name='název čísla')), + ('datum_vydani', models.DateField(blank=True, help_text='Datum vydání finální verze', null=True, verbose_name='datum vydání')), + ('verejne_db', models.BooleanField(db_column='verejne', default=False, verbose_name='číslo zveřejněno')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k číslu (plain text)', verbose_name='neveřejná poznámka')), + ('pdf', models.FileField(blank=True, help_text='PDF čísla, které si mohou řešitelé stáhnout', null=True, storage=tvorba.models.OverwriteStorage(), upload_to=tvorba.models.cislo_pdf_filename, verbose_name='pdf')), + ('titulka_nahled', models.ImageField(blank=True, help_text='Obrázek titulní strany, generuje se automaticky', null=True, upload_to=tvorba.models.cislo_png_filename, verbose_name='Obrázek titulní strany')), + ], + options={ + 'verbose_name': 'Číslo', + 'verbose_name_plural': 'Čísla', + 'db_table': 'mam_cisla', + 'ordering': ['-rocnik__rocnik', '-poradi'], + }, + ), + migrations.CreateModel( + name='Deadline', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('deadline', models.DateTimeField(default=datetime.datetime(2023, 8, 9, 21, 59, 59, 999999, tzinfo=utc))), + ('typ', models.CharField(choices=[('cisla', 'Deadline celého čísla'), ('prvni', 'První deadline'), ('prvniasous', 'Sousový a první deadline'), ('sous', 'Sousový deadline')], max_length=32, verbose_name='typ deadlinu')), + ('verejna_vysledkovka', models.BooleanField(db_column='verejna_vysledkovka', default=False, verbose_name='veřejná výsledkovka')), + ('cislo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='deadline_v_cisle', to='tvorba.Cislo', verbose_name='deadline v čísle')), + ], + options={ + 'verbose_name': 'Deadline', + 'verbose_name_plural': 'Deadliny', + 'db_table': 'mam_deadliny', + 'ordering': ['deadline'], + }, + ), + migrations.CreateModel( + name='Problem', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('nazev', models.CharField(max_length=256, verbose_name='název')), + ('stav', models.CharField(choices=[('navrh', 'Návrh'), ('zadany', 'Zadaný'), ('vyreseny', 'Vyřešený'), ('smazany', 'Smazaný')], default='navrh', max_length=32, verbose_name='stav problému')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejný návrh úlohy, návrh řešení, text zadání, poznámky ...', verbose_name='org poznámky (HTML)')), + ('kod', models.CharField(blank=True, default='', help_text='Číslo/kód úlohy v čísle nebo kód tématu/článku/seriálu v ročníku', max_length=32, verbose_name='lokální kód')), + ('vytvoreno', models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='vytvořeno')), + ('autor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='autor_problemu_problem', to='personalni.Organizator', verbose_name='autor problému')), + ('garant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='garant_problemu_problem', to='personalni.Organizator', verbose_name='garant zadaného problému')), + ('nadproblem', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='podproblem', to='tvorba.Problem', verbose_name='nadřazený problém')), + ('opravovatele', models.ManyToManyField(blank=True, related_name='opravovatele_problem', to='personalni.Organizator', verbose_name='opravovatelé')), + ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_tvorba.problem_set+', to='contenttypes.ContentType')), + ('zamereni', taggit.managers.TaggableManager(blank=True, help_text='Zaměření M/F/I/O problému, příp. další tagy', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='zaměření')), + ], + options={ + 'verbose_name': 'Problém', + 'verbose_name_plural': 'Problémy', + 'db_table': 'mam_problemy', + 'ordering': ['nazev'], + }, + ), + migrations.CreateModel( + name='Rocnik', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('prvni_rok', models.IntegerField(db_index=True, unique=True, verbose_name='první rok')), + ('rocnik', models.IntegerField(db_index=True, unique=True, verbose_name='číslo ročníku')), + ('exportovat', models.BooleanField(db_column='exportovat', default=False, help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou', verbose_name='export do AESOPa')), + ], + options={ + 'verbose_name': 'Ročník', + 'verbose_name_plural': 'Ročníky', + 'db_table': 'mam_rocniky', + 'ordering': ['-rocnik'], + }, + ), + migrations.CreateModel( + name='ZmrazenaVysledkovka', + fields=[ + ('deadline', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='vysledkovka_v_deadlinu', serialize=False, to='tvorba.Deadline')), + ('html', models.TextField()), + ], + options={ + 'verbose_name': 'Zmražená výsledkovka', + 'verbose_name_plural': 'Zmražené výsledkovky', + 'db_table': 'mam_vysledkovky', + }, + ), + migrations.CreateModel( + name='Pohadka', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('vytvoreno', models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='Vytvořeno')), + ('autor', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='personalni.Organizator', verbose_name='Autor pohádky')), + ], + options={ + 'verbose_name': 'Pohádka', + 'verbose_name_plural': 'Pohádky', + 'db_table': 'mam_pohadky', + 'ordering': ['vytvoreno'], + }, + ), + migrations.AddField( + model_name='cislo', + name='rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cisla', to='tvorba.Rocnik', verbose_name='ročník'), + ), + migrations.CreateModel( + name='Uloha', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tvorba.Problem')), + ('max_body', models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='maximum bodů')), + ('cislo_deadline', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='deadlinove_ulohy', to='tvorba.Cislo', verbose_name='číslo deadlinu')), + ('cislo_reseni', models.ForeignKey(blank=True, help_text='Číslo s řešením úlohy, jen pro úlohy', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='resene_ulohy', to='tvorba.Cislo', verbose_name='číslo řešení')), + ('cislo_zadani', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='zadane_ulohy', to='tvorba.Cislo', verbose_name='číslo zadání')), + ], + options={ + 'verbose_name': 'Úloha', + 'verbose_name_plural': 'Úlohy', + 'db_table': 'mam_ulohy', + }, + bases=('tvorba.problem',), + ), + migrations.CreateModel( + name='Tema', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tvorba.Problem')), + ('tema_typ', models.CharField(choices=[('tema', 'Téma'), ('serial', 'Seriál')], default='tema', max_length=16, verbose_name='Typ tématu')), + ('abstrakt', models.TextField(blank=True, verbose_name='Abstrakt na rozcestník')), + ('obrazek', models.ImageField(blank=True, null=True, upload_to='', verbose_name='Obrázek na rozcestník')), + ('rocnik', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='temata', to='tvorba.Rocnik', verbose_name='ročník')), + ], + options={ + 'verbose_name': 'Téma', + 'verbose_name_plural': 'Témata', + 'db_table': 'mam_temata', + }, + bases=('tvorba.problem',), + ), + migrations.CreateModel( + name='Clanek', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tvorba.Problem')), + ('cislo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vydane_clanky', to='tvorba.Cislo', verbose_name='číslo vydání')), + ], + options={ + 'verbose_name': 'Článek', + 'verbose_name_plural': 'Články', + 'db_table': 'mam_clanky', + }, + bases=('tvorba.problem',), + ), + ], + database_operations=[], + ), + ] diff --git a/tvorba/models.py b/tvorba/models.py index 42979838..ae629418 100644 --- a/tvorba/models.py +++ b/tvorba/models.py @@ -49,7 +49,7 @@ class OverwriteStorage(FileSystemStorage): class Rocnik(SeminarModelBase): class Meta: - db_table = 'seminar_rocniky' + db_table = 'mam_rocniky' verbose_name = 'Ročník' verbose_name_plural = 'Ročníky' ordering = ['-rocnik'] @@ -140,7 +140,7 @@ def cislo_png_filename(self, filename): class Cislo(SeminarModelBase): class Meta: - db_table = 'seminar_cisla' + db_table = 'mam_cisla' verbose_name = 'Číslo' verbose_name_plural = 'Čísla' ordering = ['-rocnik__rocnik', '-poradi'] @@ -338,7 +338,7 @@ class Cislo(SeminarModelBase): class Deadline(SeminarModelBase): class Meta: - db_table = 'seminar_deadliny' + db_table = 'mam_deadliny' verbose_name = 'Deadline' verbose_name_plural = 'Deadliny' ordering = ['deadline'] @@ -401,7 +401,7 @@ class Deadline(SeminarModelBase): class ZmrazenaVysledkovka(SeminarModelBase): class Meta: - db_table = 'seminar_vysledkovky' + db_table = 'mam_vysledkovky' verbose_name = 'Zmražená výsledkovka' verbose_name_plural = 'Zmražené výsledkovky' @@ -426,7 +426,7 @@ class Problem(SeminarModelBase,PolymorphicModel): # modelu Problem? #abstract = True - db_table = 'seminar_problemy' + db_table = 'mam_problemy' verbose_name = 'Problém' verbose_name_plural = 'Problémy' ordering = ['nazev'] @@ -546,7 +546,7 @@ class Problem(SeminarModelBase,PolymorphicModel): class Tema(Problem): class Meta: - db_table = 'seminar_temata' + db_table = 'mam_temata' verbose_name = 'Téma' verbose_name_plural = 'Témata' @@ -593,7 +593,7 @@ class Tema(Problem): class Clanek(Problem): class Meta: - db_table = 'seminar_clanky' + db_table = 'mam_clanky' verbose_name = 'Článek' verbose_name_plural = 'Články' @@ -616,7 +616,7 @@ class Clanek(Problem): class Uloha(Problem): class Meta: - db_table = 'seminar_ulohy' + db_table = 'mam_ulohy' verbose_name = 'Úloha' verbose_name_plural = 'Úlohy' @@ -684,7 +684,7 @@ class Pohadka(SeminarModelBase): """Kus pohádky před/za úlohou v čísle""" class Meta: - db_table = 'seminar_pohadky' + db_table = 'mam_pohadky' verbose_name = 'Pohádka' verbose_name_plural = 'Pohádky' ordering = ['vytvoreno']