From d64214c75ddd6eafda432843e9fdfac69881b582 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 13 Aug 2019 22:03:31 +0200 Subject: [PATCH] =?UTF-8?q?Models:=20Polymorphizov=C3=A1n=20Problem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0002_treenode_polymorphic_ctype.py | 20 +++++++++++++++++++ .../0003_problem_polymorphic_ctype.py | 20 +++++++++++++++++++ seminar/models.py | 3 ++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 seminar/migrations/0002_treenode_polymorphic_ctype.py create mode 100644 seminar/migrations/0003_problem_polymorphic_ctype.py diff --git a/seminar/migrations/0002_treenode_polymorphic_ctype.py b/seminar/migrations/0002_treenode_polymorphic_ctype.py new file mode 100644 index 00000000..4398be6c --- /dev/null +++ b/seminar/migrations/0002_treenode_polymorphic_ctype.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.4 on 2019-08-13 19:36 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ('seminar', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='treenode', + name='polymorphic_ctype', + field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.treenode_set+', to='contenttypes.ContentType'), + ), + ] diff --git a/seminar/migrations/0003_problem_polymorphic_ctype.py b/seminar/migrations/0003_problem_polymorphic_ctype.py new file mode 100644 index 00000000..279efbf4 --- /dev/null +++ b/seminar/migrations/0003_problem_polymorphic_ctype.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.4 on 2019-08-13 19:45 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ('seminar', '0002_treenode_polymorphic_ctype'), + ] + + operations = [ + migrations.AddField( + model_name='problem', + name='polymorphic_ctype', + field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.problem_set+', to='contenttypes.ContentType'), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index cab97533..6efd27dd 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -584,7 +584,8 @@ class Soustredeni(SeminarModelBase): @reversion.register(ignore_duplicates=True) -class Problem(SeminarModelBase): +# Pozor na následující řádek. *Nekrmit, asi kouše!* +class Problem(SeminarModelBase,PolymorphicModel): class Meta: # Není abstraktní, protože se na něj jinak nedají dělat ForeignKeys.