Skip to content

Commit

Permalink
modifies BakeryDemo guide for new ImageBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiemezuo committed Jul 26, 2024
1 parent 676f211 commit fd04062
Show file tree
Hide file tree
Showing 7 changed files with 1,006 additions and 77 deletions.
6 changes: 3 additions & 3 deletions bakerydemo/base/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
TextBlock,
)
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.blocks import ImageBlock


class ImageBlock(StructBlock):
class CaptionedImageBlock(StructBlock):
"""
Custom `StructBlock` for utilizing images with associated caption and
attribution data
"""

image = ImageChooserBlock(required=True)
image = ImageBlock(required=True)
caption = CharBlock(required=False)
attribution = CharBlock(required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,369 @@
# Generated by Django 4.2.13 on 2024-07-26 09:59

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


class Migration(migrations.Migration):

dependencies = [
("wagtailcore", "0094_alter_page_locale"),
("base", "0020_alter_footertext_options"),
]

operations = [
migrations.AlterField(
model_name="footertext",
name="locale",
field=models.ForeignKey(
editable=False,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailcore.locale",
verbose_name="locale",
),
),
migrations.AlterField(
model_name="formpage",
name="body",
field=wagtail.fields.StreamField(
[
("heading_block", 2),
("paragraph_block", 3),
("image_block", 7),
("block_quote", 10),
("embed_block", 11),
],
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "title", "required": True},
),
1: (
"wagtail.blocks.ChoiceBlock",
[],
{
"blank": True,
"choices": [
("", "Select a header size"),
("h2", "H2"),
("h3", "H3"),
("h4", "H4"),
],
"required": False,
},
),
2: (
"wagtail.blocks.StructBlock",
[[("heading_text", 0), ("size", 1)]],
{},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{"icon": "pilcrow", "template": "blocks/paragraph_block.html"},
),
4: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"required": True},
),
5: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"label": "Image is decorative",
"required": False,
},
),
6: ("wagtail.blocks.CharBlock", (), {"required": False}),
7: (
"wagtail.blocks.StructBlock",
[[("image", 4), ("decorative", 5), ("alt_text", 6)]],
{},
),
8: ("wagtail.blocks.TextBlock", (), {}),
9: (
"wagtail.blocks.CharBlock",
(),
{"blank": True, "label": "e.g. Mary Berry", "required": False},
),
10: (
"wagtail.blocks.StructBlock",
[[("text", 8), ("attribute_name", 9)]],
{},
),
11: (
"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",
},
),
},
),
),
migrations.AlterField(
model_name="gallerypage",
name="body",
field=wagtail.fields.StreamField(
[
("heading_block", 2),
("paragraph_block", 3),
("image_block", 7),
("block_quote", 10),
("embed_block", 11),
],
blank=True,
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "title", "required": True},
),
1: (
"wagtail.blocks.ChoiceBlock",
[],
{
"blank": True,
"choices": [
("", "Select a header size"),
("h2", "H2"),
("h3", "H3"),
("h4", "H4"),
],
"required": False,
},
),
2: (
"wagtail.blocks.StructBlock",
[[("heading_text", 0), ("size", 1)]],
{},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{"icon": "pilcrow", "template": "blocks/paragraph_block.html"},
),
4: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"required": True},
),
5: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"label": "Image is decorative",
"required": False,
},
),
6: ("wagtail.blocks.CharBlock", (), {"required": False}),
7: (
"wagtail.blocks.StructBlock",
[[("image", 4), ("decorative", 5), ("alt_text", 6)]],
{},
),
8: ("wagtail.blocks.TextBlock", (), {}),
9: (
"wagtail.blocks.CharBlock",
(),
{"blank": True, "label": "e.g. Mary Berry", "required": False},
),
10: (
"wagtail.blocks.StructBlock",
[[("text", 8), ("attribute_name", 9)]],
{},
),
11: (
"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",
},
),
},
verbose_name="Page body",
),
),
migrations.AlterField(
model_name="homepage",
name="body",
field=wagtail.fields.StreamField(
[
("heading_block", 2),
("paragraph_block", 3),
("image_block", 7),
("block_quote", 10),
("embed_block", 11),
],
blank=True,
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "title", "required": True},
),
1: (
"wagtail.blocks.ChoiceBlock",
[],
{
"blank": True,
"choices": [
("", "Select a header size"),
("h2", "H2"),
("h3", "H3"),
("h4", "H4"),
],
"required": False,
},
),
2: (
"wagtail.blocks.StructBlock",
[[("heading_text", 0), ("size", 1)]],
{},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{"icon": "pilcrow", "template": "blocks/paragraph_block.html"},
),
4: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"required": True},
),
5: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"label": "Image is decorative",
"required": False,
},
),
6: ("wagtail.blocks.CharBlock", (), {"required": False}),
7: (
"wagtail.blocks.StructBlock",
[[("image", 4), ("decorative", 5), ("alt_text", 6)]],
{},
),
8: ("wagtail.blocks.TextBlock", (), {}),
9: (
"wagtail.blocks.CharBlock",
(),
{"blank": True, "label": "e.g. Mary Berry", "required": False},
),
10: (
"wagtail.blocks.StructBlock",
[[("text", 8), ("attribute_name", 9)]],
{},
),
11: (
"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",
},
),
},
verbose_name="Home content block",
),
),
migrations.AlterField(
model_name="standardpage",
name="body",
field=wagtail.fields.StreamField(
[
("heading_block", 2),
("paragraph_block", 3),
("image_block", 7),
("block_quote", 10),
("embed_block", 11),
],
blank=True,
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "title", "required": True},
),
1: (
"wagtail.blocks.ChoiceBlock",
[],
{
"blank": True,
"choices": [
("", "Select a header size"),
("h2", "H2"),
("h3", "H3"),
("h4", "H4"),
],
"required": False,
},
),
2: (
"wagtail.blocks.StructBlock",
[[("heading_text", 0), ("size", 1)]],
{},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{"icon": "pilcrow", "template": "blocks/paragraph_block.html"},
),
4: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"required": True},
),
5: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"label": "Image is decorative",
"required": False,
},
),
6: ("wagtail.blocks.CharBlock", (), {"required": False}),
7: (
"wagtail.blocks.StructBlock",
[[("image", 4), ("decorative", 5), ("alt_text", 6)]],
{},
),
8: ("wagtail.blocks.TextBlock", (), {}),
9: (
"wagtail.blocks.CharBlock",
(),
{"blank": True, "label": "e.g. Mary Berry", "required": False},
),
10: (
"wagtail.blocks.StructBlock",
[[("text", 8), ("attribute_name", 9)]],
{},
),
11: (
"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",
},
),
},
verbose_name="Page body",
),
),
]
Loading

0 comments on commit fd04062

Please sign in to comment.