Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to ImageBlock #503

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 299 additions & 0 deletions wagtailio/blog/migrations/0014_add_new_imageblock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
# Generated by Django 5.0.9 on 2024-11-27 22:16

from django.db import migrations

import wagtail.fields


class Migration(migrations.Migration):
dependencies = [
("blog", "0013_alter_blogpage_body"),
]

operations = [
migrations.AlterField(
model_name="blogpage",
name="body",
field=wagtail.fields.StreamField(
[
("h2", 0),
("h3", 1),
("h4", 2),
("paragraph", 3),
("blockquote", 4),
("image", 5),
("document", 6),
("embed", 7),
("markdown", 8),
("codeblock", 11),
("teaser", 17),
("get_started_block", 18),
("sign_up_form", 19),
("highlight", 28),
("standalone_cta", 30),
],
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{
"form_classname": "title",
"icon": "title",
"template": "patterns/components/streamfields/headings/heading-2.html",
},
),
1: (
"wagtail.blocks.CharBlock",
(),
{
"form_classname": "title",
"icon": "title",
"template": "patterns/components/streamfields/headings/heading-3.html",
},
),
2: (
"wagtail.blocks.CharBlock",
(),
{
"form_classname": "title",
"icon": "title",
"template": "patterns/components/streamfields/headings/heading-4.html",
},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{
"icon": "pilcrow",
"template": "patterns/components/streamfields/rich_text_block/rich_text_block.html",
},
),
4: (
"wagtail.blocks.CharBlock",
(),
{
"form_classname": "title",
"icon": "openquote",
"template": "patterns/components/streamfields/quotes/standalone_quote_block.html",
},
),
5: (
"wagtail.images.blocks.ImageBlock",
[],
{
"icon": "image",
"template": "patterns/components/streamfields/image/image.html",
},
),
6: (
"wagtail.documents.blocks.DocumentChooserBlock",
(),
{
"icon": "doc-full-inverse",
"template": "patterns/components/streamfields/document/document.html",
},
),
7: (
"wagtail.embeds.blocks.EmbedBlock",
(),
{
"icon": "code",
"template": "patterns/components/streamfields/embed/embed.html",
},
),
8: (
"wagtailio.utils.blocks.MarkDownBlock",
(),
{
"template": "patterns/components/streamfields/code_block/code_block.html"
},
),
9: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("bash", "Bash/Shell"),
("css", "CSS"),
("django", "Django templating language"),
("html", "HTML"),
("javascript", "Javascript"),
("python", "Python"),
("scss", "SCSS"),
]
},
),
10: ("wagtail.blocks.TextBlock", (), {}),
11: (
"wagtail.blocks.StructBlock",
[[("language", 9), ("code", 10)]],
{
"template": "patterns/components/streamfields/code_block/code_block.html"
},
),
12: (
"wagtail.blocks.PageChooserBlock",
(),
{"page_type": ["blog.BlogPage"], "required": False},
),
13: ("wagtail.blocks.URLBlock", (), {"required": False}),
14: ("wagtail.images.blocks.ImageBlock", [], {}),
15: ("wagtail.blocks.TextBlock", (), {"required": False}),
16: (
"wagtail.blocks.TextBlock",
(),
{"label": "Subheading for external link", "required": False},
),
17: (
"wagtail.blocks.StructBlock",
[
[
("page", 12),
("url_chooser", 13),
("image_for_external_link", 14),
("heading_for_external_link", 15),
("subheading_for_ext_link", 16),
]
],
{"group": "CTA options"},
),
18: (
"wagtail.snippets.blocks.SnippetChooserBlock",
("core.GetStartedSnippet",),
{
"group": "CTA options",
"icon": "table-list",
"template": "patterns/components/streamfields/get_started_block/get_started_block.html",
},
),
19: (
"wagtail.snippets.blocks.SnippetChooserBlock",
("core.SignupFormSnippet",),
{
"group": "CTA options",
"icon": "envelope-open-text",
"template": "patterns/components/streamfields/sign_up_form_block/sign_up_form_block.html",
},
),
20: ("wagtail.blocks.CharBlock", (), {"max_length": 100}),
21: (
"wagtail.blocks.BooleanBlock",
(),
{"default": False, "required": False},
),
22: (
"wagtail.blocks.CharBlock",
(),
{"max_length": 50, "required": False},
),
23: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("arrow-alt", "Arrow alt"),
("arrow-in-circle", "Arrow in circle"),
("arrow-in-square", "Arrow in square"),
("arrows", "Arrows"),
("blog", "Blog"),
("bread", "Bread"),
("briefcase", "Briefcase"),
("building", "Building"),
("calendar", "Calendar"),
("code-file", "Code File"),
("document", "Document"),
("envelope", "Envelope"),
("explanation", "Explanation"),
("eye", "Eye"),
("flame", "Flame"),
("friends", "Friends"),
("github", "Github"),
("handshake", "Handshake"),
("heart", "Heart"),
("history", "History"),
("id-card", "ID Card"),
("image", "Image"),
("knife-fork", "Knife Fork"),
("leaf", "Leaf"),
("location-pin", "Location Pin"),
("map", "Map"),
("magnifying-glass", "Magnifying Glass"),
("money", "Money"),
("moon", "Moon"),
("one-two-steps", "One Two Steps"),
("padlock", "Padlock"),
("paper-plane", "Paper Plane"),
("paper-stack", "Paper Stack"),
("pen-checkbox", "Pen Checkbox"),
("person-in-tie", "Person in Tie"),
("python", "Python"),
("question-mark-circle", "Question Mark Circle"),
("quotes", "Quotes"),
("release-cycle", "Release Cycle"),
("roadmap", "Roadmap"),
("rocket", "Rocket"),
("rollback", "Rollback"),
("slack", "Slack"),
("speech-bubble", "Speech Bubble"),
("sun-cloud", "Sun Cloud"),
("table-tennis", "Table Tennis"),
("tree", "Tree"),
("wordpress", "Wordpress"),
("world", "World"),
],
"required": False,
},
),
24: (
"wagtail.blocks.CharBlock",
(),
{"label": "CTA text", "max_length": 255, "required": False},
),
25: (
"wagtail.blocks.PageChooserBlock",
(),
{"label": "CTA page", "required": False},
),
26: (
"wagtail.blocks.URLBlock",
(),
{"label": "CTA URL", "required": False},
),
27: (
"wagtail.blocks.StructBlock",
[[("text", 24), ("cta_page", 25), ("cta_url", 26)]],
{},
),
28: (
"wagtail.blocks.StructBlock",
[
[
("heading", 20),
("description", 15),
("image", 14),
("image_on_right", 21),
("meta_text", 22),
("meta_icon", 23),
("cta", 27),
]
],
{},
),
29: (
"wagtail.blocks.TextBlock",
(),
{
"label": "Short description",
"max_length": 100,
"required": False,
},
),
30: (
"wagtail.blocks.StructBlock",
[[("cta", 27), ("description", 29)]],
{"group": "CTA options"},
),
},
),
),
]
12 changes: 6 additions & 6 deletions wagtailio/core/blocks.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is an instance of ImageChooserBlock left in this file that wasn't replaced by the new ImageBlock. Did you not change it because it wasn't changed in the prior PR @Chiemezuo? Or do you have another reason for leaving it be?

See line 109 in the LogoCardBlock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks like there is another instance of ImageChooserBlock in line 463 in LogoBlock.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from wagtail.blocks.struct_block import StructBlockValidationError
from wagtail.contrib.typed_table_block.blocks import TypedTableBlock
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.blocks import ImageBlock, ImageChooserBlock
from wagtail.snippets.blocks import SnippetChooserBlock

from wagtailmedia.blocks import VideoChooserBlock
Expand Down Expand Up @@ -137,7 +137,7 @@ class TableContentBlock(blocks.StreamBlock):
rich_text = blocks.RichTextBlock(
required=False, features=["bold", "italic", "link"]
)
image = ImageChooserBlock(required=False)
image = ImageBlock(required=False)


class ComparisonTableBlock(blocks.StructBlock):
Expand Down Expand Up @@ -169,7 +169,7 @@ class Meta:
class HighlightBlock(blocks.StructBlock):
heading = blocks.CharBlock(max_length=100)
description = blocks.TextBlock(required=False)
image = ImageChooserBlock()
image = ImageBlock()
image_on_right = blocks.BooleanBlock(required=False, default=False)
meta_text = blocks.CharBlock(required=False, max_length=50)
meta_icon = blocks.ChoiceBlock(required=False, choices=SVGIcon.choices)
Expand Down Expand Up @@ -242,7 +242,7 @@ class StandaloneQuoteBlock(blocks.StructBlock):
required=True,
features=["link"],
)
author_image = ImageChooserBlock(required=False)
author_image = ImageBlock(required=False)

class Meta:
icon = "openquote"
Expand Down Expand Up @@ -289,7 +289,7 @@ class Meta:
class TeaserBlock(blocks.StructBlock):
page = blocks.PageChooserBlock(required=False, page_type=["blog.BlogPage"])
url_chooser = blocks.URLBlock(required=False)
image_for_external_link = ImageChooserBlock(required=False)
image_for_external_link = ImageBlock(required=False)
heading_for_external_link = blocks.TextBlock(required=False)
subheading_for_ext_link = blocks.TextBlock(
label="Subheading for external link", required=False
Expand Down Expand Up @@ -344,7 +344,7 @@ class Meta:


class TextAndMediaBlock(blocks.StructBlock):
image = ImageChooserBlock(required=False)
image = ImageBlock(required=False)
embed = EmbedBlock(required=False)
image_on_right = blocks.BooleanBlock(required=False, default=False)
heading = blocks.TextBlock(required=True)
Expand Down
Loading