# Generated by Django 4.1.4 on 2022-12-20 14:17

from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
import wagtail.blocks
import wagtail.contrib.table_block.blocks
import wagtail.contrib.typed_table_block.blocks
import wagtail.embeds.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("base", "0012_person_expire_at_person_expired_and_more"),
        ("wagtailcore", "0078_referenceindex"),
    ]

    operations = [
        migrations.CreateModel(
            name="RecipeIndexPage",
            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",
                    ),
                ),
                (
                    "introduction",
                    models.TextField(blank=True, help_text="Text to describe the page"),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=("wagtailcore.page",),
        ),
        migrations.CreateModel(
            name="RecipePage",
            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",
                    ),
                ),
                (
                    "date_published",
                    models.DateField(
                        blank=True, null=True, verbose_name="Date article published"
                    ),
                ),
                ("subtitle", models.CharField(blank=True, max_length=255)),
                ("introduction", models.TextField(blank=True, max_length=500)),
                (
                    "backstory",
                    wagtail.fields.StreamField(
                        [
                            (
                                "heading_block",
                                wagtail.blocks.StructBlock(
                                    [
                                        (
                                            "heading_text",
                                            wagtail.blocks.CharBlock(
                                                form_classname="title", required=True
                                            ),
                                        ),
                                        (
                                            "size",
                                            wagtail.blocks.ChoiceBlock(
                                                blank=True,
                                                choices=[
                                                    ("", "Select a header size"),
                                                    ("h2", "H2"),
                                                    ("h3", "H3"),
                                                    ("h4", "H4"),
                                                ],
                                                required=False,
                                            ),
                                        ),
                                    ]
                                ),
                            ),
                            (
                                "paragraph_block",
                                wagtail.blocks.RichTextBlock(
                                    icon="pilcrow",
                                    template="blocks/paragraph_block.html",
                                ),
                            ),
                            (
                                "image_block",
                                wagtail.blocks.StructBlock(
                                    [
                                        (
                                            "image",
                                            wagtail.images.blocks.ImageChooserBlock(
                                                required=True
                                            ),
                                        ),
                                        (
                                            "caption",
                                            wagtail.blocks.CharBlock(required=False),
                                        ),
                                        (
                                            "attribution",
                                            wagtail.blocks.CharBlock(required=False),
                                        ),
                                    ]
                                ),
                            ),
                            (
                                "block_quote",
                                wagtail.blocks.StructBlock(
                                    [
                                        ("text", wagtail.blocks.TextBlock()),
                                        (
                                            "attribute_name",
                                            wagtail.blocks.CharBlock(
                                                blank=True,
                                                label="e.g. Mary Berry",
                                                required=False,
                                            ),
                                        ),
                                    ]
                                ),
                            ),
                            (
                                "embed_block",
                                wagtail.embeds.blocks.EmbedBlock(
                                    help_text="Insert an embed URL e.g https://www.youtube.com/watch?v=SGJFWirQ3ks",
                                    icon="media",
                                    template="blocks/embed_block.html",
                                ),
                            ),
                        ],
                        blank=True,
                        help_text="Use only a minimum number of headings and large blocks.",
                        use_json_field=True,
                    ),
                ),
                (
                    "recipe_headline",
                    wagtail.fields.RichTextField(
                        blank=True, help_text="Keep to a single line", max_length=120
                    ),
                ),
                (
                    "body",
                    wagtail.fields.StreamField(
                        [
                            (
                                "heading_block",
                                wagtail.blocks.StructBlock(
                                    [
                                        (
                                            "heading_text",
                                            wagtail.blocks.CharBlock(
                                                form_classname="title", required=True
                                            ),
                                        ),
                                        (
                                            "size",
                                            wagtail.blocks.ChoiceBlock(
                                                blank=True,
                                                choices=[
                                                    ("", "Select a header size"),
                                                    ("h2", "H2"),
                                                    ("h3", "H3"),
                                                    ("h4", "H4"),
                                                ],
                                                required=False,
                                            ),
                                        ),
                                    ],
                                    group="Content",
                                ),
                            ),
                            (
                                "paragraph_block",
                                wagtail.blocks.RichTextBlock(
                                    group="Content",
                                    icon="pilcrow",
                                    template="blocks/paragraph_block.html",
                                ),
                            ),
                            (
                                "block_quote",
                                wagtail.blocks.StructBlock(
                                    [
                                        ("text", wagtail.blocks.TextBlock()),
                                        (
                                            "attribute_name",
                                            wagtail.blocks.CharBlock(
                                                blank=True,
                                                label="e.g. Mary Berry",
                                                required=False,
                                            ),
                                        ),
                                    ],
                                    group="Content",
                                ),
                            ),
                            (
                                "table_block",
                                wagtail.contrib.table_block.blocks.TableBlock(
                                    group="Content"
                                ),
                            ),
                            (
                                "typed_table_block",
                                wagtail.contrib.typed_table_block.blocks.TypedTableBlock(
                                    [
                                        ("text", wagtail.blocks.CharBlock()),
                                        ("numeric", wagtail.blocks.FloatBlock()),
                                        ("rich_text", wagtail.blocks.RichTextBlock()),
                                        (
                                            "image",
                                            wagtail.images.blocks.ImageChooserBlock(),
                                        ),
                                    ],
                                    group="Content",
                                ),
                            ),
                            (
                                "image_block",
                                wagtail.blocks.StructBlock(
                                    [
                                        (
                                            "image",
                                            wagtail.images.blocks.ImageChooserBlock(
                                                required=True
                                            ),
                                        ),
                                        (
                                            "caption",
                                            wagtail.blocks.CharBlock(required=False),
                                        ),
                                        (
                                            "attribution",
                                            wagtail.blocks.CharBlock(required=False),
                                        ),
                                    ],
                                    group="Media",
                                ),
                            ),
                            (
                                "embed_block",
                                wagtail.embeds.blocks.EmbedBlock(
                                    group="Media",
                                    help_text="Insert an embed URL e.g https://www.youtube.com/watch?v=SGJFWirQ3ks",
                                    icon="media",
                                    template="blocks/embed_block.html",
                                ),
                            ),
                            (
                                "ingredients_list",
                                wagtail.blocks.ListBlock(
                                    wagtail.blocks.RichTextBlock(
                                        features=["bold", "italic", "link"]
                                    ),
                                    group="Cooking",
                                    icon="list-ol",
                                    max_num=10,
                                    min_num=2,
                                ),
                            ),
                            (
                                "steps_list",
                                wagtail.blocks.ListBlock(
                                    wagtail.blocks.StructBlock(
                                        [
                                            (
                                                "text",
                                                wagtail.blocks.RichTextBlock(
                                                    features=["bold", "italic", "link"]
                                                ),
                                            ),
                                            (
                                                "difficulty",
                                                wagtail.blocks.ChoiceBlock(
                                                    choices=[
                                                        ("S", "Small"),
                                                        ("M", "Medium"),
                                                        ("L", "Large"),
                                                    ]
                                                ),
                                            ),
                                        ]
                                    ),
                                    group="Cooking",
                                    icon="tasks",
                                    max_num=10,
                                    min_num=2,
                                ),
                            ),
                        ],
                        blank=True,
                        help_text="The recipe’s step-by-step instructions and any other relevant information.",
                        use_json_field=True,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=("wagtailcore.page",),
        ),
        migrations.CreateModel(
            name="RecipePersonRelationship",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "sort_order",
                    models.IntegerField(blank=True, editable=False, null=True),
                ),
                (
                    "page",
                    modelcluster.fields.ParentalKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="recipe_person_relationship",
                        to="recipes.recipepage",
                    ),
                ),
                (
                    "person",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="person_recipe_relationship",
                        to="base.person",
                    ),
                ),
            ],
            options={
                "ordering": ["sort_order"],
                "abstract": False,
            },
        ),
    ]
