# Generated by Django 3.0.6 on 2020-07-11 10:57

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks


# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# pages.migrations.0006_main_page

class Migration(migrations.Migration):

    replaces = [('pages', '0001_initial'), ('pages', '0002_auto_20200427_1903'), ('pages', '0003_auto_20200427_2015'), ('pages', '0004_remove_home_app'), ('pages', '0005_auto_20200430_1654'), ('pages', '0006_main_page'), ('pages', '0007_auto_20200528_1605')]

    initial = True

    dependencies = [
        ('wagtailcore', '0045_assign_unlock_grouppagepermission'),
        ('wagtailimages', '0001_squashed_0021'),
        ('wagtailimages', '0022_uploadedimage'),
    ]

    def create_homepage(apps, schema_editor):
        # Get models
        ContentType = apps.get_model('contenttypes.ContentType')
        Page = apps.get_model('wagtailcore.Page')
        Site = apps.get_model('wagtailcore.Site')
        HomePage = apps.get_model('pages.StaticPage')

        # Delete the default homepage
        # If migration is run multiple times, it may have already been deleted
        Page.objects.filter(id=2).delete()

        # Create content type for homepage model
        homepage_content_type, __ = ContentType.objects.get_or_create(
            model='staticpage', app_label='pages')

        # Create a new homepage
        homepage = HomePage.objects.create(
            title="Home",
            draft_title="Home",
            slug='home',
            content_type=homepage_content_type,
            path='00010001',
            depth=2,
            numchild=0,
            url_path='/home/',
            locale_id=1,
        )

        # Create a site with the new homepage set as the root
        Site.objects.create(
            hostname='localhost', root_page=homepage, is_default_site=True)

    def remove_homepage(apps, schema_editor):
        # Get models
        ContentType = apps.get_model('contenttypes.ContentType')
        HomePage = apps.get_model('pages.StaticPage')

        # Delete the default homepage
        # Page and Site objects CASCADE
        HomePage.objects.filter(slug='home', depth=2).delete()

        # Delete content type for homepage model
        ContentType.objects.filter(model='staticpage', app_label='pages').delete()

    operations = [
        migrations.CreateModel(
            name='StaticPage',
            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')),
                ('content', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))])),
                ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
                ('content_en', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], null=True)),
                ('content_pl', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], null=True)),
            ],
            options={
                'abstract': False,
            },
            bases=('wagtailcore.page',),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_en',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_pl',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.RunPython(
            code=create_homepage, reverse_code=remove_homepage,
        ),
        migrations.AlterModelOptions(
            name='staticpage',
            options={'verbose_name': 'page', 'verbose_name_plural': 'pages'},
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_en',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_pl',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='featured_image',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='featured image'),
        ),
    ]

# Generated by Django 3.0.6 on 2020-07-11 10:57

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks


# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# pages.migrations.0006_main_page

class Migration(migrations.Migration):

    replaces = [('pages', '0001_initial'), ('pages', '0002_auto_20200427_1903'), ('pages', '0003_auto_20200427_2015'), ('pages', '0004_remove_home_app'), ('pages', '0005_auto_20200430_1654'), ('pages', '0006_main_page'), ('pages', '0007_auto_20200528_1605')]

    initial = True

    dependencies = [
        ('wagtailcore', '0045_assign_unlock_grouppagepermission'),
        ('wagtailimages', '0001_squashed_0021'),
        ('wagtailimages', '0022_uploadedimage'),
    ]

    def create_homepage(apps, schema_editor):
        # Get models
        ContentType = apps.get_model('contenttypes.ContentType')
        Page = apps.get_model('wagtailcore.Page')
        Site = apps.get_model('wagtailcore.Site')
        HomePage = apps.get_model('pages.StaticPage')

        # Delete the default homepage
        # If migration is run multiple times, it may have already been deleted
        Page.objects.filter(id=2).delete()

        # Create content type for homepage model
        homepage_content_type, __ = ContentType.objects.get_or_create(
            model='staticpage', app_label='pages')

        # Create a new homepage
        homepage = HomePage.objects.create(
            title="Home",
            draft_title="Home",
            slug='home',
            content_type=homepage_content_type,
            path='00010001',
            depth=2,
            numchild=0,
            url_path='/home/',
            locale_id=1,
        )

        # Create a site with the new homepage set as the root
        Site.objects.create(
            hostname='localhost', root_page=homepage, is_default_site=True)

    def remove_homepage(apps, schema_editor):
        # Get models
        ContentType = apps.get_model('contenttypes.ContentType')
        HomePage = apps.get_model('pages.StaticPage')

        # Delete the default homepage
        # Page and Site objects CASCADE
        HomePage.objects.filter(slug='home', depth=2).delete()

        # Delete content type for homepage model
        ContentType.objects.filter(model='staticpage', app_label='pages').delete()

    operations = [
        migrations.CreateModel(
            name='StaticPage',
            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')),
                ('content', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))])),
                ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
                ('content_en', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], null=True)),
                ('content_pl', wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], null=True)),
            ],
            options={
                'abstract': False,
            },
            bases=('wagtailcore.page',),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_en',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_pl',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True),
        ),
        migrations.RunPython(
            code=create_homepage, reverse_code=remove_homepage,
        ),
        migrations.AlterModelOptions(
            name='staticpage',
            options={'verbose_name': 'page', 'verbose_name_plural': 'pages'},
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_en',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='content_pl',
            field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('post_index', wagtail.core.blocks.StructBlock([('index', wagtail.core.blocks.PageChooserBlock(page_type=['blog.PostIndex'])), ('shown_posts', wagtail.core.blocks.IntegerBlock(min_value=1))]))], blank=True, null=True, verbose_name='content'),
        ),
        migrations.AlterField(
            model_name='staticpage',
            name='featured_image',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='featured image'),
        ),
    ]

# Generated by Django 3.0.6 on 2020-07-11 10:57 # Functions from the following migrations need manual copying. # Move them and any dependencies into this file, then update the # RunPython operations to refer to the local versions: # pages.migrations.0006_main_page # Get models # Delete the default homepage # If migration is run multiple times, it may have already been deleted # Create content type for homepage model # Create a new homepage # Create a site with the new homepage set as the root # Get models # Delete the default homepage # Page and Site objects CASCADE # Delete content type for homepage model