From 6f34355303c109ae862f30e2af8161eb59dfab24 Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 26 Jul 2024 11:18:59 -0400 Subject: [PATCH] holy cow --- pages/custom_blocks.py | 9 +- pages/migrations/0149_alter_rootpage_body.py | 990 +++++++++++++++++++ pages/models.py | 2 + 3 files changed, 996 insertions(+), 5 deletions(-) create mode 100644 pages/migrations/0149_alter_rootpage_body.py diff --git a/pages/custom_blocks.py b/pages/custom_blocks.py index 62a082e0f..f6fb3e5ec 100644 --- a/pages/custom_blocks.py +++ b/pages/custom_blocks.py @@ -96,8 +96,10 @@ class LinksGroupBlock(blocks.StructBlock): ('blue', 'Blue'), ('deep-green', 'Deep Green'), ], default='descending')), + ('analytics_label', blocks.CharBlock(required=False)), ], block_counts={ 'color': {'max_num': 1}, + 'analytics_label': {'max_num': 1}, }, required=False) class Meta: @@ -110,12 +112,9 @@ class CTAButtonBarBlock(blocks.StructBlock): default=[], max_num=2, label='Actions' ) config = blocks.StreamBlock([ - ('priority', blocks.ChoiceBlock(choices=[ - ('descending', 'Descending'), - ('equal', 'Equal'), - ], default='descending')), + ('analytics_label', blocks.CharBlock(required=False)), ], block_counts={ - 'priority': {'max_num': 1}, + 'analytics_label': {'max_num': 1}, }, required=False) class Meta: diff --git a/pages/migrations/0149_alter_rootpage_body.py b/pages/migrations/0149_alter_rootpage_body.py new file mode 100644 index 000000000..a2d4fe4d8 --- /dev/null +++ b/pages/migrations/0149_alter_rootpage_body.py @@ -0,0 +1,990 @@ +# Generated by Django 5.0.7 on 2024-07-26 15:18 + +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", "0148_alter_rootpage_layout"), + ] + + 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=[ + ( + "orange", + "Orange", + ), + ( + "white", + "White", + ), + ( + "blue_outline", + "Blue Outline", + ), + ( + "deep_green_outline", + "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=[ + ("orange", "Orange"), + ("white", "White"), + ( + "blue_outline", + "Blue Outline", + ), + ( + "deep_green_outline", + "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( + [ + ( + "analytics_label", + wagtail.blocks.CharBlock(required=False), + ) + ], + block_counts={"analytics_label": {"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"), + ] + ), + ), + ( + "analytics_label", + wagtail.blocks.CharBlock(required=False), + ), + ], + block_counts={ + "analytics_label": {"max_num": 1}, + "color": {"max_num": 1}, + }, + required=False, + ), + ), + ] + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ("image", pages.custom_blocks.APIImageChooserBlock()), + ("content", wagtail.blocks.RichTextBlock()), + ("name", wagtail.blocks.CharBlock()), + ("title", wagtail.blocks.CharBlock(requred=False)), + ] + ), + ), + ( + "faq", + wagtail.blocks.StreamBlock( + [ + ( + "faq", + wagtail.blocks.StructBlock( + [ + ( + "question", + wagtail.blocks.RichTextBlock(required=True), + ), + ("slug", wagtail.blocks.CharBlock(required=True)), + ( + "answer", + wagtail.blocks.RichTextBlock(required=True), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + required=False + ), + ), + ] + ), + ) + ] + ), + ), + ] + ), + ), + ("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=[ + ( + "orange", + "Orange", + ), + ( + "white", + "White", + ), + ( + "blue_outline", + "Blue Outline", + ), + ( + "deep_green_outline", + "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=[ + ("orange", "Orange"), + ("white", "White"), + ( + "blue_outline", + "Blue Outline", + ), + ( + "deep_green_outline", + "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( + [ + ( + "analytics_label", + wagtail.blocks.CharBlock(required=False), + ) + ], + block_counts={"analytics_label": {"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"), + ] + ), + ), + ( + "analytics_label", + wagtail.blocks.CharBlock(required=False), + ), + ], + block_counts={ + "analytics_label": {"max_num": 1}, + "color": {"max_num": 1}, + }, + required=False, + ), + ), + ] + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ("image", pages.custom_blocks.APIImageChooserBlock()), + ("content", wagtail.blocks.RichTextBlock()), + ("name", wagtail.blocks.CharBlock()), + ("title", wagtail.blocks.CharBlock(requred=False)), + ] + ), + ), + ( + "faq", + wagtail.blocks.StreamBlock( + [ + ( + "faq", + wagtail.blocks.StructBlock( + [ + ( + "question", + wagtail.blocks.RichTextBlock(required=True), + ), + ("slug", wagtail.blocks.CharBlock(required=True)), + ( + "answer", + wagtail.blocks.RichTextBlock(required=True), + ), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + 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\\-_]", + ), + ), + ( + "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 + ), + ), + ( + "padding_top", + wagtail.blocks.IntegerBlock( + help_text="Padding multiplier. default 0.", min_value=0 + ), + ), + ( + "padding_bottom", + wagtail.blocks.IntegerBlock( + help_text="Padding multiplier. default 0.", min_value=0 + ), + ), + ( + "text_alignment", + wagtail.blocks.ChoiceBlock( + choices=[("center", "Center"), ("left", "Left"), ("right", "Right")] + ), + ), + ("analytics_label", wagtail.blocks.CharBlock(required=False)), + ], + block_counts={ + "analytics_label": {"max_num": 1}, + "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, + ), + ), + ] diff --git a/pages/models.py b/pages/models.py index 8c5cdb7fc..efe21f2d5 100644 --- a/pages/models.py +++ b/pages/models.py @@ -155,11 +155,13 @@ class RootPage(Page): ('left', 'Left'), ('right', 'Right'), ], default='left')), + ('analytics_label', blocks.CharBlock(required=False)), ], block_counts={ 'id': {'max_num': 1}, 'background_color': {'max_num': 1}, 'padding': {'max_num': 1}, 'text_alignment': {'max_num': 1}, + 'analytics_label': {'max_num': 1}, }, required=False)) ])), ('divider', DividerBlock()),