Skip to content
Merged
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
27 changes: 23 additions & 4 deletions bedrock/mozorg/blocks/anonym.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.templatetags.static import static

from wagtail import blocks
from wagtail.contrib.table_block.blocks import TableBlock
from wagtail.images.blocks import ImageChooserBlock
from wagtail_link_block.blocks import LinkBlock
from wagtail_thumbnail_choice_block import ThumbnailChoiceBlock
Expand All @@ -20,6 +21,10 @@
]


SECTION_THEME_INDEX = "index"
SECTION_THEME_TOP_GLOW = "top_glow"


ICON_CHOICES = [
("IRL", "IRL"),
("accessibility", "Accessibility"),
Expand Down Expand Up @@ -429,15 +434,27 @@ class Meta:
label_format = "Cards List - {heading}"


class SectionBlockSettingsValue(blocks.StructValue):
"""Custom value class to make properties available in templates."""

@property
def has_index_theme(self) -> bool:
return self.get("theme") == SECTION_THEME_INDEX

@property
def has_top_glow_theme(self) -> bool:
return self.get("theme") == SECTION_THEME_TOP_GLOW


class SectionBlockSettings(blocks.StructBlock):
theme = ThumbnailChoiceBlock(
choices=(
("index", "Index"),
("top_glow", "Top Glow"),
(SECTION_THEME_INDEX, "Index"),
(SECTION_THEME_TOP_GLOW, "Top Glow"),
),
thumbnails={
"index": "/media/img/icons/index.svg",
"top_glow": "/media/img/icons/top_glow.svg",
SECTION_THEME_INDEX: "/media/img/icons/index.svg",
SECTION_THEME_TOP_GLOW: "/media/img/icons/top_glow.svg",
},
inline_form=True,
required=False,
Expand All @@ -449,6 +466,7 @@ class Meta:
label = "Settings"
label_format = "Theme: {theme}"
form_classname = "compact-form struct-block"
value_class = SectionBlockSettingsValue


class SectionBlock(blocks.StructBlock):
Expand All @@ -468,6 +486,7 @@ class SectionBlock(blocks.StructBlock):
("cards_list", CardsListBlock()),
("stats_list_block", StatsListBlock()),
("people_list", PeopleListBlock()),
("table", TableBlock()),
],
required=False,
)
Expand Down
57 changes: 29 additions & 28 deletions bedrock/mozorg/migrations/0022_anonymindexpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Migration(migrations.Migration):
(
"content",
wagtail.fields.StreamField(
[("section", 36), ("call_to_action", 38)],
[("section", 37), ("call_to_action", 39)],
blank=True,
block_lookup={
0: (
Expand Down Expand Up @@ -375,13 +375,14 @@ class Migration(migrations.Migration):
20: ("wagtail.blocks.StructBlock", [[("stats", 19)]], {}),
21: ("wagtail.blocks.ListBlock", (6,), {"default": [], "max_num": 8, "min_num": 1}),
22: ("wagtail.blocks.StructBlock", [[("people_photos", 21), ("text", 13)]], {}),
23: (
23: ("wagtail.contrib.table_block.blocks.TableBlock", (), {}),
24: (
"wagtail.blocks.StreamBlock",
[[("figure_block", 7), ("cards_list", 16), ("stats_list_block", 20), ("people_list", 22)]],
[[("figure_block", 7), ("cards_list", 16), ("stats_list_block", 20), ("people_list", 22), ("table", 23)]],
{"required": False},
),
24: ("wagtail.blocks.CharBlock", (), {"label": "Link Text"}),
25: (
25: ("wagtail.blocks.CharBlock", (), {"label": "Link Text"}),
26: (
"wagtail.blocks.ChoiceBlock",
[],
{
Expand All @@ -398,13 +399,13 @@ class Migration(migrations.Migration):
"required": False,
},
),
26: ("wagtail.blocks.PageChooserBlock", (), {"form_classname": "page_link", "label": "Page", "required": False}),
27: (
27: ("wagtail.blocks.PageChooserBlock", (), {"form_classname": "page_link", "label": "Page", "required": False}),
28: (
"wagtail.documents.blocks.DocumentChooserBlock",
(),
{"form_classname": "file_link", "label": "File", "required": False},
),
28: (
29: (
"wagtail.blocks.CharBlock",
(),
{
Expand All @@ -415,63 +416,63 @@ class Migration(migrations.Migration):
"validators": [wagtail.admin.forms.choosers.URLOrAbsolutePathValidator()],
},
),
29: (
30: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "anchor_link", "label": "#", "max_length": 300, "required": False},
),
30: ("wagtail.blocks.EmailBlock", (), {"required": False}),
31: (
31: ("wagtail.blocks.EmailBlock", (), {"required": False}),
32: (
"wagtail.blocks.CharBlock",
(),
{"form_classname": "phone_link", "label": "Phone", "max_length": 30, "required": False},
),
32: (
33: (
"wagtail.blocks.BooleanBlock",
(),
{"form_classname": "new_window_toggle", "label": "Open in new window", "required": False},
),
33: (
34: (
"wagtail.blocks.StructBlock",
[
[
("link_to", 25),
("page", 26),
("file", 27),
("custom_url", 28),
("anchor", 29),
("email", 30),
("phone", 31),
("new_window", 32),
("link_to", 26),
("page", 27),
("file", 28),
("custom_url", 29),
("anchor", 30),
("email", 31),
("phone", 32),
("new_window", 33),
]
],
{},
),
34: ("wagtail.blocks.StructBlock", [[("label", 24), ("link", 33)]], {}),
35: ("wagtail.blocks.ListBlock", (34,), {"default": [], "max_num": 1, "min_num": 0}),
36: (
35: ("wagtail.blocks.StructBlock", [[("label", 25), ("link", 34)]], {}),
36: ("wagtail.blocks.ListBlock", (35,), {"default": [], "max_num": 1, "min_num": 0}),
37: (
"wagtail.blocks.StructBlock",
[
[
("settings", 1),
("superheading_text", 2),
("heading_text", 3),
("subheading_text", 2),
("section_content", 23),
("action", 35),
("section_content", 24),
("action", 36),
]
],
{},
),
37: (
38: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": ["bold", "italic", "link", "superscript", "subscript", "strikethrough"],
"help_text": "Use <strong>bold</strong> to make parts of this text black.",
},
),
38: ("wagtail.blocks.StructBlock", [[("heading", 37), ("button", 35)]], {}),
39: ("wagtail.blocks.StructBlock", [[("heading", 38), ("button", 36)]], {}),
},
null=True,
),
Expand Down
Loading