# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-10 11:39
from __future__ import unicode_literals

import c3nav.mapdata.fields
from django.db import migrations, models
import django.db.models.deletion


def create_location_group_category(apps, schema_editor):
    LocationGroupCategory = apps.get_model('mapdata', 'LocationGroupCategory')
    category = LocationGroupCategory.objects.create(name='groups', titles={
        'en': 'Location Groups',
        'de': 'Ortgruppen',
    })
    LocationGroup = apps.get_model('mapdata', 'LocationGroup')
    LocationGroup.objects.update(category=category)


class Migration(migrations.Migration):

    dependencies = [
        ('mapdata', '0018_auto_20170708_1752'),
    ]

    operations = [
        migrations.CreateModel(
            name='LocationGroupCategory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('titles', c3nav.mapdata.fields.JSONField(default={})),
                ('name', models.SlugField(unique=True, verbose_name='Name')),
            ],
            options={
                'verbose_name': 'Location Group Category',
                'verbose_name_plural': 'Location Group Categories',
                'default_related_name': 'locationgroupcategories',
            },
        ),
        migrations.AlterModelOptions(
            name='locationslug',
            options={'verbose_name': 'Location with Slug', 'verbose_name_plural': 'Location with Slug'},
        ),
        migrations.AddField(
            model_name='locationgroup',
            name='category',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='groups', to='mapdata.LocationGroupCategory', verbose_name='Location Group Category'),
        ),
        migrations.RunPython(create_location_group_category, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='locationgroup',
            name='category',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='groups',
                                    to='mapdata.LocationGroupCategory', verbose_name='Location Group Category'),
        ),
    ]
