Browse Source

Fix

middleware_test
Pavel "LEdoian" Turinsky 4 years ago
parent
commit
f26f4a5c0f
  1. 4
      seminar/migrations/0087_fix_polymorphism.py

4
seminar/migrations/0087_fix_polymorphism.py

@ -25,7 +25,7 @@ def fix_ctypes(parent: str, children, apps, schema_editor):
# Ostatní instance mají mít explicitně content type pro rodiče # Ostatní instance mají mít explicitně content type pro rodiče
new_ct = ContentType.objects.get_for_model(Parent) new_ct = ContentType.objects.get_for_model(Parent)
for obj in Parent.objects.filter(polymorphic_ctype__isnull=True): for obj in Parent.objects.filter(polymorphic_ctype__isnull=True):
log.warn(f"{parent} {obj} neměl content type -- nejspíš to je instance přímo {parent}!") log.warn(f"{parent} \"{obj}\" neměl content type -- nejspíš to je instance přímo {parent}!")
obj.polymorphic_ctype=new_ct obj.polymorphic_ctype=new_ct
obj.save() obj.save()
@ -36,7 +36,7 @@ def fix_treenode(apps, schema_editor):
fix_ctypes("TreeNode", children, apps, schema_editor) fix_ctypes("TreeNode", children, apps, schema_editor)
def fix_problem(apps, schema_editor): def fix_problem(apps, schema_editor):
children = ['Tema', 'Clanek', 'Uloha', 'Konfera'] children = ['Tema', 'Clanek', 'Uloha'] # FIXME: Konfera z nějakého důvodu tenhle field vůbec nemá, asi je to špatně.
fix_ctypes("Problem", children, apps, schema_editor) fix_ctypes("Problem", children, apps, schema_editor)
class Migration(migrations.Migration): class Migration(migrations.Migration):

Loading…
Cancel
Save