# Generated by Django 3.2.11 on 2022-01-27 12:43

from django.db import migrations

from spritstat.models import Location, LocationType


def set_name(apps, schema_editor):
    # Create the name from the address/city/plz/region_name fields

    locations = Location.objects.all()

    for loc in locations:
        if loc.type == LocationType.NAMED:
            loc.name = f"{loc.address}, {loc.postal_code} {loc.city}"
        else:
            loc.name = loc.region_name

        loc.save()


class Migration(migrations.Migration):

    dependencies = [
        ("spritstat", "0007_auto_20220127_1203"),
    ]

    operations = [
        migrations.RunPython(set_name),
    ]

# Generated by Django 3.2.11 on 2022-01-27 12:43

from django.db import migrations

from spritstat.models import Location, LocationType


def set_name(apps, schema_editor):
    # Create the name from the address/city/plz/region_name fields

    locations = Location.objects.all()

    for loc in locations:
        if loc.type == LocationType.NAMED:
            loc.name = f"{loc.address}, {loc.postal_code} {loc.city}"
        else:
            loc.name = loc.region_name

        loc.save()


class Migration(migrations.Migration):

    dependencies = [
        ("spritstat", "0007_auto_20220127_1203"),
    ]

    operations = [
        migrations.RunPython(set_name),
    ]

# Generated by Django 3.2.11 on 2022-01-27 12:43 # Create the name from the address/city/plz/region_name fields