29 lines
1 KiB
Python
29 lines
1 KiB
Python
# Generated by Django 6.0.7 on 2026-08-11 12:13
|
|
|
|
import django.db.models.deletion
|
|
from django.db import migrations, models
|
|
|
|
|
|
def populate_locations(apps, schema_editor):
|
|
NatureRWIZ = apps.get_model('assets', 'NatureRWIZ')
|
|
NatureRWIAsset = apps.get_model('assets', 'NatureRWIAsset')
|
|
|
|
zones = NatureRWIZ.objects.filter(geom__isnull=False)
|
|
for zone in zones:
|
|
NatureRWIAsset.objects.filter(geom__intersects=zone.geom, location__isnull=True).update(location=zone)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('assets', '0018_remove_parkingspot_scooter_capacity'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='naturerwiasset',
|
|
name='location',
|
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assets', to='assets.naturerwiz', verbose_name='Zone GIEP / ZIEP'),
|
|
),
|
|
migrations.RunPython(populate_locations, reverse_code=migrations.RunPython.noop),
|
|
]
|