Skip to content

Commit 7f4d7b2

Browse files
author
Arne Tarara - Automated
committed
Merge remote-tracking branch 'upstream/main' into gmt-pinned-versions
2 parents cd97e04 + 7c19ba7 commit 7f4d7b2

File tree

9 files changed

+1212
-28
lines changed

9 files changed

+1212
-28
lines changed

bakerydemo/base/blocks.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,37 @@ class Meta:
8181
description = "A heading with level two, three, or four"
8282

8383

84+
class ThemeSettingsBlock(StructBlock):
85+
theme = ChoiceBlock(
86+
choices=[
87+
("default", "Default"),
88+
("highlight", "Highlight"),
89+
],
90+
required=False,
91+
default="default",
92+
)
93+
text_size = ChoiceBlock(
94+
choices=[
95+
("default", "Default"),
96+
("large", "Large"),
97+
],
98+
required=False,
99+
default="default",
100+
)
101+
102+
class Meta:
103+
icon = "cog"
104+
label_format = "Theme: {theme}, Text size: {text_size}"
105+
106+
84107
class BlockQuote(StructBlock):
85108
"""
86109
Custom `StructBlock` that allows the user to attribute a quote to the author
87110
"""
88111

89112
text = TextBlock()
90113
attribute_name = CharBlock(blank=True, required=False, label="e.g. Mary Berry")
114+
settings = ThemeSettingsBlock(collapsed=True)
91115

92116
class Meta:
93117
icon = "openquote"

bakerydemo/base/migrations/0026_alter_formpage_body_alter_gallerypage_body_and_more.py

Lines changed: 448 additions & 0 deletions
Large diffs are not rendered by default.

bakerydemo/base/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class FormPage(AbstractEmailForm):
550550

551551

552552
@register_setting(icon="cog")
553-
class GenericSettings(ClusterableModel, BaseGenericSetting):
553+
class GenericSettings(ClusterableModel, PreviewableMixin, BaseGenericSetting):
554554
mastodon_url = models.URLField(verbose_name="Mastodon URL", blank=True)
555555
github_url = models.URLField(verbose_name="GitHub URL", blank=True)
556556
organisation_url = models.URLField(verbose_name="Organisation URL", blank=True)
@@ -566,6 +566,9 @@ class GenericSettings(ClusterableModel, BaseGenericSetting):
566566
)
567567
]
568568

569+
def get_preview_template(self, request, mode_name):
570+
return "base.html"
571+
569572

570573
@register_setting(icon="site")
571574
class SiteSettings(BaseSiteSetting):
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Generated by Django 5.2.1 on 2025-07-28 19:37
2+
3+
import wagtail.fields
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("blog", "0007_alter_blogpage_body"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="blogpage",
16+
name="body",
17+
field=wagtail.fields.StreamField(
18+
[
19+
("heading_block", 2),
20+
("paragraph_block", 3),
21+
("image_block", 6),
22+
("block_quote", 12),
23+
("embed_block", 13),
24+
],
25+
blank=True,
26+
block_lookup={
27+
0: (
28+
"wagtail.blocks.CharBlock",
29+
(),
30+
{"form_classname": "title", "required": True},
31+
),
32+
1: (
33+
"wagtail.blocks.ChoiceBlock",
34+
[],
35+
{
36+
"blank": True,
37+
"choices": [
38+
("", "Select a header size"),
39+
("h2", "H2"),
40+
("h3", "H3"),
41+
("h4", "H4"),
42+
],
43+
"required": False,
44+
},
45+
),
46+
2: (
47+
"wagtail.blocks.StructBlock",
48+
[[("heading_text", 0), ("size", 1)]],
49+
{},
50+
),
51+
3: (
52+
"wagtail.blocks.RichTextBlock",
53+
(),
54+
{
55+
"description": "A rich text paragraph",
56+
"icon": "pilcrow",
57+
"preview_value": '\n <h2>Our bread pledge</h2>\n <p>As a bakery, <b>breads</b> have <i>always</i> been in our hearts.\n <a href="https://en.wikipedia.org/wiki/Staple_food">Staple foods</a>\n are essential for society, and – bread is the tastiest of all.\n We love to transform batters and doughs into baked goods with a firm\n dry crust and fluffy center.</p>\n ',
58+
"template": "blocks/paragraph_block.html",
59+
},
60+
),
61+
4: (
62+
"wagtail.images.blocks.ImageChooserBlock",
63+
(),
64+
{"required": True},
65+
),
66+
5: ("wagtail.blocks.CharBlock", (), {"required": False}),
67+
6: (
68+
"wagtail.blocks.StructBlock",
69+
[[("image", 4), ("caption", 5), ("attribution", 5)]],
70+
{},
71+
),
72+
7: ("wagtail.blocks.TextBlock", (), {}),
73+
8: (
74+
"wagtail.blocks.CharBlock",
75+
(),
76+
{"blank": True, "label": "e.g. Mary Berry", "required": False},
77+
),
78+
9: (
79+
"wagtail.blocks.ChoiceBlock",
80+
[],
81+
{
82+
"choices": [
83+
("default", "Default"),
84+
("highlight", "Highlight"),
85+
],
86+
"required": False,
87+
},
88+
),
89+
10: (
90+
"wagtail.blocks.ChoiceBlock",
91+
[],
92+
{
93+
"choices": [("default", "Default"), ("large", "Large")],
94+
"required": False,
95+
},
96+
),
97+
11: (
98+
"wagtail.blocks.StructBlock",
99+
[[("theme", 9), ("text_size", 10)]],
100+
{"collapsed": True},
101+
),
102+
12: (
103+
"wagtail.blocks.StructBlock",
104+
[[("text", 7), ("attribute_name", 8), ("settings", 11)]],
105+
{},
106+
),
107+
13: (
108+
"wagtail.embeds.blocks.EmbedBlock",
109+
(),
110+
{
111+
"description": "An embedded video or other media",
112+
"help_text": "Insert an embed URL e.g https://www.youtube.com/watch?v=SGJFWirQ3ks",
113+
"icon": "media",
114+
"preview_template": "base/preview/static_embed_block.html",
115+
"preview_value": "https://www.youtube.com/watch?v=mwrGSfiB1Mg",
116+
"template": "blocks/embed_block.html",
117+
},
118+
),
119+
},
120+
verbose_name="Page body",
121+
),
122+
),
123+
]
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Generated by Django 5.2.1 on 2025-07-28 19:37
2+
3+
import wagtail.fields
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("breads", "0008_alter_breadpage_body"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="breadpage",
16+
name="body",
17+
field=wagtail.fields.StreamField(
18+
[
19+
("heading_block", 2),
20+
("paragraph_block", 3),
21+
("image_block", 6),
22+
("block_quote", 12),
23+
("embed_block", 13),
24+
],
25+
blank=True,
26+
block_lookup={
27+
0: (
28+
"wagtail.blocks.CharBlock",
29+
(),
30+
{"form_classname": "title", "required": True},
31+
),
32+
1: (
33+
"wagtail.blocks.ChoiceBlock",
34+
[],
35+
{
36+
"blank": True,
37+
"choices": [
38+
("", "Select a header size"),
39+
("h2", "H2"),
40+
("h3", "H3"),
41+
("h4", "H4"),
42+
],
43+
"required": False,
44+
},
45+
),
46+
2: (
47+
"wagtail.blocks.StructBlock",
48+
[[("heading_text", 0), ("size", 1)]],
49+
{},
50+
),
51+
3: (
52+
"wagtail.blocks.RichTextBlock",
53+
(),
54+
{
55+
"description": "A rich text paragraph",
56+
"icon": "pilcrow",
57+
"preview_value": '\n <h2>Our bread pledge</h2>\n <p>As a bakery, <b>breads</b> have <i>always</i> been in our hearts.\n <a href="https://en.wikipedia.org/wiki/Staple_food">Staple foods</a>\n are essential for society, and – bread is the tastiest of all.\n We love to transform batters and doughs into baked goods with a firm\n dry crust and fluffy center.</p>\n ',
58+
"template": "blocks/paragraph_block.html",
59+
},
60+
),
61+
4: (
62+
"wagtail.images.blocks.ImageChooserBlock",
63+
(),
64+
{"required": True},
65+
),
66+
5: ("wagtail.blocks.CharBlock", (), {"required": False}),
67+
6: (
68+
"wagtail.blocks.StructBlock",
69+
[[("image", 4), ("caption", 5), ("attribution", 5)]],
70+
{},
71+
),
72+
7: ("wagtail.blocks.TextBlock", (), {}),
73+
8: (
74+
"wagtail.blocks.CharBlock",
75+
(),
76+
{"blank": True, "label": "e.g. Mary Berry", "required": False},
77+
),
78+
9: (
79+
"wagtail.blocks.ChoiceBlock",
80+
[],
81+
{
82+
"choices": [
83+
("default", "Default"),
84+
("highlight", "Highlight"),
85+
],
86+
"required": False,
87+
},
88+
),
89+
10: (
90+
"wagtail.blocks.ChoiceBlock",
91+
[],
92+
{
93+
"choices": [("default", "Default"), ("large", "Large")],
94+
"required": False,
95+
},
96+
),
97+
11: (
98+
"wagtail.blocks.StructBlock",
99+
[[("theme", 9), ("text_size", 10)]],
100+
{"collapsed": True},
101+
),
102+
12: (
103+
"wagtail.blocks.StructBlock",
104+
[[("text", 7), ("attribute_name", 8), ("settings", 11)]],
105+
{},
106+
),
107+
13: (
108+
"wagtail.embeds.blocks.EmbedBlock",
109+
(),
110+
{
111+
"description": "An embedded video or other media",
112+
"help_text": "Insert an embed URL e.g https://www.youtube.com/watch?v=SGJFWirQ3ks",
113+
"icon": "media",
114+
"preview_template": "base/preview/static_embed_block.html",
115+
"preview_value": "https://www.youtube.com/watch?v=mwrGSfiB1Mg",
116+
"template": "blocks/embed_block.html",
117+
},
118+
),
119+
},
120+
verbose_name="Page body",
121+
),
122+
),
123+
]

0 commit comments

Comments
 (0)