forked from enviPath/enviPy
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# Generated by Django 6.0.3 on 2026-08-14 07:41
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def forward_func(apps, schema_editor):
|
|
ContentType = apps.get_model("contenttypes", "ContentType")
|
|
AdditionalInformation = apps.get_model("epdb", "AdditionalInformation")
|
|
|
|
models = {}
|
|
|
|
for c in ContentType.objects.all():
|
|
try:
|
|
models[(c.app_label, c.model)] = apps.get_model(c.app_label, c.model)
|
|
except Exception:
|
|
pass
|
|
|
|
for ai in AdditionalInformation.objects.all():
|
|
if ai.url is None:
|
|
if ai.content_type is None:
|
|
ai.url = "{}/additional-information/{}".format(ai.scenario.url, ai.uuid)
|
|
else:
|
|
model = models[(ai.content_type.app_label, ai.content_type.model)]
|
|
obj = model.objects.get(pk=ai.object_id)
|
|
ai.url = "{}/additional-information/{}".format(obj.url, ai.uuid)
|
|
|
|
ai.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("epdb", "0029_reactionexplanation_reaction_explained_by"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(forward_func, reverse_code=migrations.RunPython.noop),
|
|
]
|