# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-25 10:19
from __future__ import unicode_literals

from django.db import migrations, models


def add_short_label(apps, schema_editor):
    models = ('AltitudeArea', 'AltitudeMarker', 'Area', 'Building', 'Column', 'Door', 'GraphNode', 'Hole',
              'LineObstacle', 'Obstacle', 'POI', 'Space', 'Stair')
    Level = apps.get_model('mapdata', 'level')
    for level in Level.objects.all():
        level.short_label = level.slug or str(level.pk)
        level.save()

def remove_short_label(apps, schema_editor):
    pass


class Migration(migrations.Migration):

    dependencies = [
        ('mapdata', '0040_access_permissions'),
    ]

    operations = [
        migrations.AddField(
            model_name='level',
            name='short_label',
            field=models.CharField(null=True, max_length=20, unique=True, verbose_name='short label'),
        ),
        migrations.RunPython(add_short_label, remove_short_label),
        migrations.AlterField(
            model_name='level',
            name='short_label',
            field=models.CharField(max_length=20, unique=True, verbose_name='short label'),
        ),
    ]
