diff --git a/etna/core/blocks/__init__.py b/etna/core/blocks/__init__.py index ba5b992d1..c1593bfd2 100644 --- a/etna/core/blocks/__init__.py +++ b/etna/core/blocks/__init__.py @@ -19,7 +19,7 @@ ) from .quote import QuoteBlock from .section import SectionBlock, SubHeadingBlock -from .text import InsetTextBlock +from .text import InsetTextBlock, WarningTextBlock __all__ = [ "APIPageChooserBlock", @@ -46,4 +46,5 @@ "SectionBlock", "SectionDepthAwareStructBlock", "SubHeadingBlock", + "WarningTextBlock", ] diff --git a/etna/core/blocks/lists.py b/etna/core/blocks/lists.py index da903ece2..054400556 100644 --- a/etna/core/blocks/lists.py +++ b/etna/core/blocks/lists.py @@ -16,6 +16,6 @@ class DoDontListBlock(blocks.StructBlock): ) class Meta: - icon = "list-ul" + icon = "tasks" label = "Do/Don't List" template = "blocks/do-dont-list.html" diff --git a/etna/core/blocks/text.py b/etna/core/blocks/text.py index 0232527ad..105e9560d 100644 --- a/etna/core/blocks/text.py +++ b/etna/core/blocks/text.py @@ -11,3 +11,15 @@ class InsetTextBlock(blocks.StructBlock): class Meta: icon = "indent" label = "Inset text" + + +class WarningTextBlock(blocks.StructBlock): + heading = blocks.CharBlock( + required=False, + help_text="Optional heading for the warning text, for screen readers", + ) + body = APIRichTextBlock(features=settings.RESTRICTED_RICH_TEXT_FEATURES) + + class Meta: + icon = "warning" + label = "Warning text" diff --git a/etna/generic_pages/blocks.py b/etna/generic_pages/blocks.py index 66c6f3cbf..cf52b139d 100644 --- a/etna/generic_pages/blocks.py +++ b/etna/generic_pages/blocks.py @@ -13,6 +13,7 @@ QuoteBlock, SectionDepthAwareStructBlock, SubHeadingBlock, + WarningTextBlock, ) from ..media.blocks import MediaBlock @@ -33,6 +34,7 @@ class SectionContentBlock(blocks.StreamBlock): quote = QuoteBlock() record_links = RecordLinksBlock() sub_heading = SubHeadingBlock() + warning_text = WarningTextBlock() class ContentSectionBlock(SectionDepthAwareStructBlock): diff --git a/etna/generic_pages/migrations/0015_alter_generalpage_body.py b/etna/generic_pages/migrations/0015_alter_generalpage_body.py new file mode 100644 index 000000000..c075d616c --- /dev/null +++ b/etna/generic_pages/migrations/0015_alter_generalpage_body.py @@ -0,0 +1,569 @@ +# Generated by Django 5.0.6 on 2024-07-02 11:56 +# etna:allowAlterField + +import etna.core.blocks.image +import etna.core.blocks.page_chooser +import etna.core.blocks.paragraph +import etna.media.blocks +import etna.records.blocks +import wagtail.blocks +import wagtail.fields +import wagtail.snippets.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("generic_pages", "0014_hubpage"), + ] + + operations = [ + migrations.AlterField( + model_name="generalpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "content_section", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + label="Heading", max_length=100 + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "label", + wagtail.blocks.CharBlock(), + ), + ( + "link", + etna.core.blocks.page_chooser.APIPageChooserBlock( + required=False + ), + ), + ( + "external_link", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "accented", + wagtail.blocks.BooleanBlock( + help_text="Use the accented button style", + label="Accented", + required=False, + ), + ), + ] + ), + ), + ( + "call_to_action", + wagtail.blocks.StructBlock( + [ + ( + "body", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + "ol", + "ul", + ], + max_length=100, + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "label", + wagtail.blocks.CharBlock(), + ), + ( + "link", + etna.core.blocks.page_chooser.APIPageChooserBlock( + required=False + ), + ), + ( + "external_link", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "accented", + wagtail.blocks.BooleanBlock( + help_text="Use the accented button style", + label="Accented", + required=False, + ), + ), + ] + ), + ), + ] + ), + ), + ( + "do_dont_list", + wagtail.blocks.StructBlock( + [ + ( + "do", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ] + ), + ) + ], + icon="check", + label="Do item", + ), + label="Dos", + ), + ), + ( + "dont", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "text", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ] + ), + ) + ], + icon="cross", + label="Don't item", + ), + label="Don'ts", + ), + ), + ] + ), + ), + ( + "featured_record_article", + wagtail.blocks.StructBlock( + [ + ( + "page", + etna.core.blocks.page_chooser.APIPageChooserBlock( + label="Page", + page_type=[ + "articles.RecordArticlePage" + ], + required_api_fields=[ + "teaser_image" + ], + ), + ) + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + etna.core.blocks.image.APIImageChooserBlock( + rendition_size="max-900x900", + required=True, + ), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text='Alternative (alt) text describes images when they fail to load, and is read aloud by assistive technologies. Use a maximum of 100 characters to describe your image. Check the guidance for tips on writing alt text.', + label="Alternative text", + max_length=100, + ), + ), + ( + "caption", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ], + help_text="If provided, displays directly below the image. Can be used to specify sources, transcripts or other useful metadata.", + label="Caption (optional)", + required=False, + ), + ), + ] + ), + ), + ( + "inset_text", + wagtail.blocks.StructBlock( + [ + ( + "text", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + "ol", + "ul", + ] + ), + ) + ] + ), + ), + ( + "media", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="A descriptive title for the media block", + required=True, + ), + ), + ( + "background_image", + etna.core.blocks.image.APIImageChooserBlock( + help_text="A background image for the media block" + ), + ), + ( + "media", + etna.media.blocks.MediaChooserBlock(), + ), + ] + ), + ), + ( + "paragraph", + wagtail.blocks.StructBlock( + [ + ( + "text", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + "ol", + "ul", + ] + ), + ) + ] + ), + ), + ( + "promoted_item", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the promoted page", + label="Title", + max_length=100, + ), + ), + ( + "category", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "blog", + "Blog post", + ), + ( + "podcast", + "Podcast", + ), + ("video", "Video"), + ( + "video-external", + "External video", + ), + ( + "external-link", + "External link", + ), + ], + label="Category", + ), + ), + ( + "publication_date", + wagtail.blocks.CharBlock( + help_text="This is a free text field. Please enter date as per agreed format: 14 April 2021", + required=False, + ), + ), + ( + "author", + wagtail.blocks.CharBlock( + required=False + ), + ), + ( + "duration", + wagtail.blocks.CharBlock( + help_text="Podcast or video duration.", + label="Duration", + max_length=50, + required=False, + ), + ), + ( + "url", + wagtail.blocks.URLBlock( + help_text="URL for the external page", + label="External URL", + ), + ), + ( + "target_blank", + wagtail.blocks.BooleanBlock( + label="Should this URL open in a new tab?
Tick the box if 'yes'
", + required=False, + ), + ), + ( + "cta_label", + wagtail.blocks.CharBlock( + help_text="The text displayed on the button for your URL. If your URL links to an external site, please add the name of the site users will land on, and what they will find on this page. For example 'Watch our short film about Shakespeare on YouTube'.", + label="Call to action label", + max_length=50, + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + etna.core.blocks.image.APIImageChooserBlock( + rendition_size="max-900x900", + required=True, + ), + ), + ( + "decorative", + wagtail.blocks.BooleanBlock( + default=False, + help_text='Decorative images are used for visual effect and do not add information to the content of a page. "Check the guidance to see if your image is decorative.', + label="Is this image decorative?Tick the box if 'yes'
", + required=False, + ), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text='Alternative (alt) text describes images when they fail to load, and is read aloud by assistive technologies. Use a maximum of 100 characters to describe your image. Decorative images do not require alt text. Check the guidance for tips on writing alt text.', + label="Image alternative text", + max_length=100, + required=False, + ), + ), + ], + label="Teaser image", + template="articles/blocks/images/blog-embed__image-container.html", + ), + ), + ( + "description", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ], + help_text="A description of the promoted page", + ), + ), + ] + ), + ), + ( + "promoted_list", + wagtail.blocks.StructBlock( + [ + ( + "category", + wagtail.snippets.blocks.SnippetChooserBlock( + "categories.Category" + ), + ), + ( + "summary", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ], + required=False, + ), + ), + ( + "promoted_items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="The title of the target page", + max_length=100, + required=True, + ), + ), + ( + "description", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ], + help_text="A description of the target page", + required=False, + ), + ), + ( + "url", + wagtail.blocks.URLBlock( + required=True + ), + ), + ] + ) + ), + ), + ] + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ( + "quote", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + ], + required=True, + ), + ), + ( + "attribution", + wagtail.blocks.CharBlock( + max_length=100, + required=False, + ), + ), + ] + ), + ), + ( + "record_links", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + etna.records.blocks.RecordLinkBlock, + label="Items", + ), + ) + ] + ), + ), + ( + "sub_heading", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + label="Sub-heading", + max_length=100, + ), + ) + ] + ), + ), + ( + "warning_text", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + help_text="Optional heading for the warning text, for screen readers", + required=False, + ), + ), + ( + "body", + etna.core.blocks.paragraph.APIRichTextBlock( + features=[ + "bold", + "italic", + "link", + "ol", + "ul", + ] + ), + ), + ] + ), + ), + ], + required=False, + ), + ), + ] + ), + ) + ], + blank=True, + null=True, + ), + ), + ]