Browse Source

Migrace: Přidat content-types, !možná blbě!, tabs, oprava pořadí.

export_seznamu_prednasek
Pavel "LEdoian" Turinsky 5 years ago
parent
commit
2d23a79ad6
  1. 20
      seminar/migrations/0002_treenode_polymorphic_ctype.py
  2. 20
      seminar/migrations/0003_problem_polymorphic_ctype.py
  3. 31
      seminar/migrations/0065_treenode_polymorphic_ctype.py
  4. 29
      seminar/migrations/0066_problem_polymorphic_ctype.py

20
seminar/migrations/0002_treenode_polymorphic_ctype.py

@ -1,20 +0,0 @@
# 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'),
),
]

20
seminar/migrations/0003_problem_polymorphic_ctype.py

@ -1,20 +0,0 @@
# 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'),
),
]

31
seminar/migrations/0065_treenode_polymorphic_ctype.py

@ -0,0 +1,31 @@
# Generated by Django 2.2.4 on 2019-08-13 19:36
from django.db import migrations, models
import django.db.models.deletion
def vyrob_treenodum_ctypes(apps, schema_editor):
# Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html
# XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i)
TreeNode = apps.get_model('seminar', 'TreeNode')
ContentType = apps.get_model('contenttypes', 'ContentType')
new_ct = ContentType.objects.get_for_model(TreeNode)
TreeNode.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct)
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('seminar', '0064_auto_20190610_2358'),
]
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'),
),
migrations.RunPython(vyrob_treenodum_ctypes, migrations.RunPython.noop),
]

29
seminar/migrations/0066_problem_polymorphic_ctype.py

@ -0,0 +1,29 @@
# Generated by Django 2.2.4 on 2019-08-13 19:45
from django.db import migrations, models
import django.db.models.deletion
def vyrob_problemum_ctypes(apps, schema_editor):
# Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html
# XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i)
Problem = apps.get_model('seminar', 'Problem')
ContentType = apps.get_model('contenttypes', 'ContentType')
new_ct = ContentType.objects.get_for_model(Problem)
Problem.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct)
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('seminar', '0065_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'),
),
migrations.RunPython(vyrob_problemum_ctypes, migrations.RunPython.noop),
]
Loading…
Cancel
Save