diff --git a/pages/custom_blocks.py b/pages/custom_blocks.py index 62f4e59a2..43f83c764 100644 --- a/pages/custom_blocks.py +++ b/pages/custom_blocks.py @@ -56,11 +56,30 @@ def get_api_representation(self, value, context=None): return None -class CTALinkBlock(blocks.StructBlock): +class LinkInfoBlock(blocks.StructBlock): text = blocks.CharBlock(required=True) aria_label = blocks.CharBlock(required=False) target = LinkBlock(required=True) + class Meta: + icon = 'placeholder' + label = "Link" + +class CTALinkBlock(LinkInfoBlock): + text = blocks.CharBlock(required=True) + aria_label = blocks.CharBlock(required=False) + target = LinkBlock(required=True) + config = blocks.StreamBlock([ + ('style', blocks.ChoiceBlock(choices=[ + ('primary', 'Primary'), + ('white', 'White'), + ('blue-outline', 'Blue Outline'), + ('deep-green', 'Deep Green Outline'), + ], default='descending')), + ], block_counts={ + 'style': {'max_num': 1}, + }, required=False) + class Meta: icon = 'placeholder' label = "Call to Action" @@ -68,7 +87,7 @@ class Meta: class LinksGroupBlock(blocks.StructBlock): links = blocks.ListBlock( - CTALinkBlock(required=False, label="Link"), + LinkInfoBlock(required=False, label="Link"), default=[], label='Links' ) config = blocks.StreamBlock([ diff --git a/pages/migrations/0143_alter_rootpage_body_alter_rootpage_layout.py b/pages/migrations/0143_alter_rootpage_body_alter_rootpage_layout.py new file mode 100644 index 000000000..b3283c636 --- /dev/null +++ b/pages/migrations/0143_alter_rootpage_body_alter_rootpage_layout.py @@ -0,0 +1,985 @@ +# Generated by Django 5.0.7 on 2024-07-25 12:29 + +import pages.custom_blocks +import wagtail.blocks +import wagtail.documents.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("pages", "0142_alter_rootpage_body"), + ] + + operations = [ + migrations.AlterField( + model_name="rootpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "hero", + wagtail.blocks.StructBlock( + [ + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "cards_block", + wagtail.blocks.StructBlock( + [ + ( + "cards", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + pages.custom_blocks.APIRichTextBlock(), + ), + ( + "cta_block", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + required=True + ), + ), + ( + "aria_label", + wagtail.blocks.CharBlock( + required=False + ), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "style", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "primary", + "Primary", + ), + ( + "white", + "White", + ), + ( + "blue-outline", + "Blue Outline", + ), + ( + "deep-green", + "Deep Green Outline", + ), + ] + ), + ) + ], + block_counts={ + "style": { + "max_num": 1 + } + }, + required=False, + ), + ), + ], + label="Link", + required=False, + ), + default=[], + label="Call To Action", + max_num=1, + ), + ), + ] + ) + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "card_size", + wagtail.blocks.IntegerBlock( + help_text="Width multiplier. default 27.", + min_value=0, + ), + ), + ( + "card_style", + wagtail.blocks.ChoiceBlock( + choices=[ + ("rounded", "Rounded"), + ("square", "Square"), + ] + ), + ), + ], + block_counts={ + "card_size": {"max_num": 1}, + "card_style": {"max_num": 1}, + }, + required=False, + ), + ), + ], + label="Cards Block", + ), + ), + ("text", pages.custom_blocks.APIRichTextBlock()), + ("html", wagtail.blocks.RawHTMLBlock()), + ( + "cta_block", + wagtail.blocks.StructBlock( + [ + ( + "actions", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(required=True), + ), + ( + "aria_label", + wagtail.blocks.CharBlock(required=False), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "style", + wagtail.blocks.ChoiceBlock( + choices=[ + ("primary", "Primary"), + ("white", "White"), + ( + "blue-outline", + "Blue Outline", + ), + ( + "deep-green", + "Deep Green Outline", + ), + ] + ), + ) + ], + block_counts={"style": {"max_num": 1}}, + required=False, + ), + ), + ], + label="Button", + required=False, + ), + default=[], + label="Actions", + max_num=2, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "priority", + wagtail.blocks.ChoiceBlock( + choices=[ + ("descending", "Descending"), + ("equal", "Equal"), + ] + ), + ) + ], + block_counts={"priority": {"max_num": 1}}, + required=False, + ), + ), + ] + ), + ), + ( + "links_group", + wagtail.blocks.StructBlock( + [ + ( + "links", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(required=True), + ), + ( + "aria_label", + wagtail.blocks.CharBlock(required=False), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ], + label="Link", + required=False, + ), + default=[], + label="Links", + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "color", + wagtail.blocks.ChoiceBlock( + choices=[ + ("white", "White"), + ("blue", "Blue"), + ("deep-green", "Deep Green"), + ] + ), + ) + ], + block_counts={"color": {"max_num": 1}}, + required=False, + ), + ), + ] + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ("image", pages.custom_blocks.APIImageChooserBlock()), + ("content", wagtail.blocks.RichTextBlock()), + ] + ), + ), + ] + ), + ), + ("image", pages.custom_blocks.APIImageChooserBlock(required=False)), + ("image_alt", wagtail.blocks.CharBlock(required=False)), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "id", + wagtail.blocks.RegexBlock( + error_mssages={"invalid": "not a valid id."}, + help_text="html id of this element. eg: cool_section", + regex="[a-zA-Z0-9\\-_]", + ), + ), + ( + "image_alignment", + wagtail.blocks.ChoiceBlock( + choices=[ + ("left", "Left"), + ("right", "Right"), + ("topLeft", "Top Left"), + ("topRight", "Top Right"), + ("bottomLeft", "Bottom Left"), + ("bottomRight", "Bottom Right"), + ] + ), + ), + ( + "image_size", + wagtail.blocks.ChoiceBlock( + choices=[ + ("auto", "Auto"), + ("contain", "Contain"), + ("cover", "Cover"), + ] + ), + ), + ( + "padding", + wagtail.blocks.IntegerBlock( + help_text="Padding multiplier. default 0.", min_value=0 + ), + ), + ( + "background_color", + wagtail.blocks.RegexBlock( + error_mssages={"invalid": "not a valid hex color."}, + help_text="eg: #ff0000", + regex="#[a-zA-Z0-9]{6}", + ), + ), + ], + block_counts={ + "background_color": {"max_num": 1}, + "id": {"max_num": 1}, + "image_alignment": {"max_num": 1}, + "image_size": {"max_num": 1}, + "padding": {"max_num": 1}, + }, + required=False, + ), + ), + ] + ), + ), + ( + "section", + wagtail.blocks.StructBlock( + [ + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "cards_block", + wagtail.blocks.StructBlock( + [ + ( + "cards", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + pages.custom_blocks.APIRichTextBlock(), + ), + ( + "cta_block", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + required=True + ), + ), + ( + "aria_label", + wagtail.blocks.CharBlock( + required=False + ), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "style", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "primary", + "Primary", + ), + ( + "white", + "White", + ), + ( + "blue-outline", + "Blue Outline", + ), + ( + "deep-green", + "Deep Green Outline", + ), + ] + ), + ) + ], + block_counts={ + "style": { + "max_num": 1 + } + }, + required=False, + ), + ), + ], + label="Link", + required=False, + ), + default=[], + label="Call To Action", + max_num=1, + ), + ), + ] + ) + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "card_size", + wagtail.blocks.IntegerBlock( + help_text="Width multiplier. default 27.", + min_value=0, + ), + ), + ( + "card_style", + wagtail.blocks.ChoiceBlock( + choices=[ + ("rounded", "Rounded"), + ("square", "Square"), + ] + ), + ), + ], + block_counts={ + "card_size": {"max_num": 1}, + "card_style": {"max_num": 1}, + }, + required=False, + ), + ), + ], + label="Cards Block", + ), + ), + ("text", pages.custom_blocks.APIRichTextBlock()), + ("html", wagtail.blocks.RawHTMLBlock()), + ( + "cta_block", + wagtail.blocks.StructBlock( + [ + ( + "actions", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(required=True), + ), + ( + "aria_label", + wagtail.blocks.CharBlock(required=False), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "style", + wagtail.blocks.ChoiceBlock( + choices=[ + ("primary", "Primary"), + ("white", "White"), + ( + "blue-outline", + "Blue Outline", + ), + ( + "deep-green", + "Deep Green Outline", + ), + ] + ), + ) + ], + block_counts={"style": {"max_num": 1}}, + required=False, + ), + ), + ], + label="Button", + required=False, + ), + default=[], + label="Actions", + max_num=2, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "priority", + wagtail.blocks.ChoiceBlock( + choices=[ + ("descending", "Descending"), + ("equal", "Equal"), + ] + ), + ) + ], + block_counts={"priority": {"max_num": 1}}, + required=False, + ), + ), + ] + ), + ), + ( + "links_group", + wagtail.blocks.StructBlock( + [ + ( + "links", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(required=True), + ), + ( + "aria_label", + wagtail.blocks.CharBlock(required=False), + ), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ( + "external", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "internal", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ( + "anchor", + wagtail.blocks.CharBlock( + required=False + ), + ), + ], + required=True, + ), + ), + ], + label="Link", + required=False, + ), + default=[], + label="Links", + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "color", + wagtail.blocks.ChoiceBlock( + choices=[ + ("white", "White"), + ("blue", "Blue"), + ("deep-green", "Deep Green"), + ] + ), + ) + ], + block_counts={"color": {"max_num": 1}}, + required=False, + ), + ), + ] + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ("image", pages.custom_blocks.APIImageChooserBlock()), + ("content", wagtail.blocks.RichTextBlock()), + ] + ), + ), + ] + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "id", + wagtail.blocks.RegexBlock( + error_mssages={"invalid": "not a valid id."}, + help_text="html id of this element. eg: cool_section", + regex="[a-zA-Z0-9\\-_]", + ), + ), + ( + "background_color", + wagtail.blocks.RegexBlock( + error_mssages={"invalid": "not a valid hex color."}, + help_text="eg: #ff0000", + regex="#[a-zA-Z0-9]{6}", + ), + ), + ( + "padding", + wagtail.blocks.IntegerBlock( + help_text="Padding multiplier. default 0.", min_value=0 + ), + ), + ( + "text_alignment", + wagtail.blocks.ChoiceBlock( + choices=[("center", "Center"), ("left", "Left"), ("right", "Right")] + ), + ), + ], + block_counts={ + "background_color": {"max_num": 1}, + "id": {"max_num": 1}, + "padding": {"max_num": 1}, + "text_alignment": {"max_num": 1}, + }, + required=False, + ), + ), + ] + ), + ), + ( + "divider", + wagtail.blocks.StructBlock( + [ + ("image", pages.custom_blocks.APIImageChooserBlock()), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "alignment", + wagtail.blocks.ChoiceBlock( + choices=[ + ("center", "Center"), + ("content_left", "Left side of content."), + ("content_right", "Right side of content."), + ("body_left", "Left side of window."), + ("body_right", "Right side of window."), + ] + ), + ), + ( + "width", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "must be valid css measurement. eg: 30px, 50%, 10rem" + }, + regex="^[0-9]+(px|%|rem)$", + required=False, + ), + ), + ( + "height", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "must be valid css measurement. eg: 30px, 50%, 10rem" + }, + regex="^[0-9]+(px|%|rem)$", + required=False, + ), + ), + ( + "offset_vertical", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "must be valid css measurement. eg: 30px, 50%, 10rem" + }, + regex="^\\-?[0-9]+(px|%|rem)$", + required=False, + ), + ), + ( + "offset_horizontal", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "must be valid css measurement. eg: 30px, 50%, 10rem" + }, + regex="^\\-?[0-9]+(px|%|rem)$", + required=False, + ), + ), + ], + block_counts={ + "alignment": {"max_num": 1}, + "height": {"max_num": 1}, + "offset_horizontal": {"max_num": 1}, + "offset_vertical": {"max_num": 1}, + "width": {"max_num": 1}, + }, + required=False, + ), + ), + ] + ), + ), + ("html", wagtail.blocks.RawHTMLBlock()), + ], + use_json_field=True, + ), + ), + migrations.AlterField( + model_name="rootpage", + name="layout", + field=wagtail.fields.StreamField( + [ + ("default", wagtail.blocks.StructBlock([])), + ( + "landing", + wagtail.blocks.StructBlock( + [ + ( + "nav_links", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ("text", wagtail.blocks.CharBlock(required=True)), + ("aria_label", wagtail.blocks.CharBlock(required=False)), + ( + "target", + wagtail.blocks.StreamBlock( + [ + ("external", wagtail.blocks.URLBlock(required=False)), + ( + "internal", + wagtail.blocks.PageChooserBlock(required=False), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ("anchor", wagtail.blocks.CharBlock(required=False)), + ], + required=True, + ), + ), + ( + "config", + wagtail.blocks.StreamBlock( + [ + ( + "style", + wagtail.blocks.ChoiceBlock( + choices=[ + ("primary", "Primary"), + ("white", "White"), + ("blue-outline", "Blue Outline"), + ("deep-green", "Deep Green Outline"), + ] + ), + ) + ], + block_counts={"style": {"max_num": 1}}, + required=False, + ), + ), + ], + label="Link", + required=False, + ), + default=[], + label="Nav Links", + ), + ) + ], + label="Landing Page", + ), + ), + ], + blank=True, + default=[], + use_json_field=True, + ), + ), + ]