# Generated by Django 2.2.9 on 2020-11-19 09:24

from django.db import migrations, models
import django.db.models.deletion

from application.models import HelsinkiActivities, LandingPages, BannerPagesFolder, BannerPages


def migrate_banner_data(app, schema_editor):
    helsinki_activities = HelsinkiActivities.objects.first()
    if not helsinki_activities:
        # Return if nothing to do
        return
    landing_pages = LandingPages.objects.all()
    banner_pages_folder = helsinki_activities.add_child(instance=BannerPagesFolder(title='Banner Pages'))
    for page in landing_pages:
        top_banner = banner_pages_folder.add_child(instance=BannerPages(
            title=page.title_fi,
            title_fi=page.title_fi, title_sv=page.title_sv, title_en=page.title_en,
            description_fi=page.description_fi, description_sv=page.description_sv, description_en=page.description_en,
            button_text_fi=page.button_text_fi, button_text_sv=page.button_text_sv,button_text_en=page.button_text_en,
            button_url_fi=page.button_url_fi, button_url_sv=page.button_url_sv, button_url_en=page.button_url_en,
            hero_background_image_fi=page.hero_background_image_fi, hero_background_image_sv=page.hero_background_image_sv, hero_background_image_en=page.hero_background_image_en,
            hero_background_image_mobile_fi=page.hero_background_image_mobile_fi, hero_background_image_mobile_sv=page.hero_background_image_mobile_sv, hero_background_image_mobile_en=page.hero_background_image_mobile_en,
            hero_top_layer_image_fi=page.hero_top_layer_image_fi, hero_top_layer_image_sv=page.hero_top_layer_image_sv, hero_top_layer_image_en=page.hero_top_layer_image_en,
            social_media_image_fi=page.social_media_image_fi, social_media_image_sv=page.social_media_image_sv, social_media_image_en=page.social_media_image_en))
        page.top_banner = top_banner
        page.save()


class Migration(migrations.Migration):

    dependencies = [
        ('wagtailcore', '0052_pagelogentry'),
        ('application', '0048_auto_20201120_1237'),
    ]

    operations = [
        migrations.CreateModel(
            name='BannerPagesFolder',
            fields=[
                ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
            ],
            options={
                'verbose_name': 'Banner Pages Folder',
            },
            bases=('wagtailcore.page',),
        ),
        migrations.CreateModel(
            name='BannerPages',
            fields=[
                ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
                ('hero_background_image_color_fi', models.CharField(blank=True, choices=[('FOG', 'Sumu'), ('ENGEL', 'Engel'), ('COPPER', 'Kupari'), ('SUOMENLINNA', 'Suomenlinna')], max_length=255, null=True, verbose_name='Pääkuvan taustaväri FI')),
                ('hero_background_image_color_sv', models.CharField(blank=True, choices=[('FOG', 'Sumu'), ('ENGEL', 'Engel'), ('COPPER', 'Kupari'), ('SUOMENLINNA', 'Suomenlinna')], max_length=255, null=True, verbose_name='Pääkuvan taustaväri SV')),
                ('hero_background_image_color_en', models.CharField(blank=True, choices=[('FOG', 'Sumu'), ('ENGEL', 'Engel'), ('COPPER', 'Kupari'), ('SUOMENLINNA', 'Suomenlinna')], max_length=255, null=True, verbose_name='Pääkuvan taustaväri EN')),
                ('button_text_fi', models.CharField(max_length=255, null=True, verbose_name='Napin teksti FI')),
                ('button_text_sv', models.CharField(max_length=255, null=True, verbose_name='Napin teksti SV')),
                ('button_text_en', models.CharField(max_length=255, null=True, verbose_name='Napin teksti EN')),
                ('button_url_fi', models.URLField(max_length=500, null=True, verbose_name='Linkki suomenkieliselle sivulle')),
                ('button_url_sv', models.URLField(max_length=500, null=True, verbose_name='Linkki ruotsinkieliselle sivulle')),
                ('button_url_en', models.URLField(max_length=500, null=True, verbose_name='Linkki englanninkieliselle sivulle')),
                ('title_fi', models.CharField(max_length=255, null=True, verbose_name='Otsikko FI')),
                ('title_sv', models.CharField(max_length=255, null=True, verbose_name='Otsikko SV')),
                ('title_en', models.CharField(max_length=255, null=True, verbose_name='Otsikko EN')),
                ('title_and_description_color_fi', models.CharField(blank=True, choices=[('BLACK', 'Black'), ('WHITE', 'White')], max_length=255, null=True, verbose_name='Tekstin väri FI')),
                ('title_and_description_color_sv', models.CharField(blank=True, choices=[('BLACK', 'Black'), ('WHITE', 'White')], max_length=255, null=True, verbose_name='Tekstin väri SV')),
                ('title_and_description_color_en', models.CharField(blank=True, choices=[('BLACK', 'Black'), ('WHITE', 'White')], max_length=255, null=True, verbose_name='Tekstin väri EN')),
                ('description_fi', models.TextField(blank=True, null=True, verbose_name='Selite FI')),
                ('description_sv', models.TextField(blank=True, null=True, verbose_name='Selite SV')),
                ('description_en', models.TextField(blank=True, null=True, verbose_name='Selite EN')),
                ('hero_background_image_en', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva EN')),
                ('hero_background_image_fi', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva FI')),
                ('hero_background_image_mobile_en', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva mobiililla EN')),
                ('hero_background_image_mobile_fi', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva mobiililla FI')),
                ('hero_background_image_mobile_sv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva mobiililla SV')),
                ('hero_background_image_sv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuva SV')),
                ('hero_top_layer_image_en', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuvan päälle asettuva kuva EN')),
                ('hero_top_layer_image_fi', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuvan päälle asettuva kuva FI')),
                ('hero_top_layer_image_sv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Pääkuvan päälle asettuva kuva SV')),
                ('social_media_image_en', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Some-postauksen kuva EN')),
                ('social_media_image_fi', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Some-postauksen kuva FI')),
                ('social_media_image_sv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.CustomImage', verbose_name='Some-postauksen kuva SV')),
            ],
            options={
                'verbose_name': 'Banner',
            },
            bases=('wagtailcore.page',),
        ),
        migrations.AddField(
            model_name='landingpages',
            name='bottom_banner',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.BannerPages', verbose_name='Bottom banner'),
        ),
        migrations.AddField(
            model_name='landingpages',
            name='top_banner',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='application.BannerPages', verbose_name='Top banner'),
        ),
        migrations.RunPython(migrate_banner_data, migrations.RunPython.noop)
    ]
