# Generated by Django 5.0.8 on 2024-09-06 12:04

from django.db import migrations, models


def forwards_func(apps, schema_editor):
    LocationGroup = apps.get_model('mapdata', 'LocationGroup')
    for group in LocationGroup.objects.all():
        group.in_legend = bool(group.color and (group.can_describe or group.can_search))
        group.save()
    ObstacleGroup = apps.get_model('mapdata', 'ObstacleGroup')
    ObstacleGroup.objects.filter(color__isnull=False).update(in_legend=True)


class Migration(migrations.Migration):

    dependencies = [
        ('mapdata', '0107_altitudearea_multiple_points'),
    ]

    operations = [
        migrations.AddField(
            model_name='locationgroup',
            name='in_legend',
            field=models.BooleanField(default=False, verbose_name='show in legend (if color set)'),
        ),
        migrations.AlterField(
            model_name='beaconmeasurement',
            name='data',
            field=models.JSONField(default=dict, verbose_name='Measurement list'),
        ),
        migrations.AddField(
            model_name='obstaclegroup',
            name='in_legend',
            field=models.BooleanField(default=False, verbose_name='show in legend (if color set)'),
        ),
        migrations.RunPython(forwards_func, migrations.RunPython.noop),
    ]
