diff --git a/etna/api/tests/expected_results/article.json b/etna/api/tests/expected_results/article.json index 839a371b4..ef81c7cc8 100644 --- a/etna/api/tests/expected_results/article.json +++ b/etna/api/tests/expected_results/article.json @@ -335,7 +335,7 @@ "title": "arts", "url": "/arts/", "full_url": "http://localhost/arts/", - "type_label": "Topic", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 2, @@ -361,7 +361,7 @@ "title": "early_modern", "url": "/early_modern/", "full_url": "http://localhost/early_modern/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 4, @@ -385,7 +385,7 @@ "title": "postwar", "url": "/postwar/", "full_url": "http://localhost/postwar/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 6, diff --git a/etna/api/tests/expected_results/article_index.json b/etna/api/tests/expected_results/article_index.json index ff9531b0e..df6003fb9 100644 --- a/etna/api/tests/expected_results/article_index.json +++ b/etna/api/tests/expected_results/article_index.json @@ -62,7 +62,7 @@ }, "title": "article_index", "global_alert": null, - "type_label": "Article index", + "type_label": null, "mourning_notice": { "title": "Test title", "message": "

Test message

" diff --git a/etna/api/tests/expected_results/arts.json b/etna/api/tests/expected_results/arts.json index dd90029ab..037ac9d97 100644 --- a/etna/api/tests/expected_results/arts.json +++ b/etna/api/tests/expected_results/arts.json @@ -105,7 +105,7 @@ "custom_sensitive_image": null }, "global_alert": null, - "type_label": "Topic", + "type_label": "Explore the collection", "mourning_notice": { "title": "Test title", "message": "

Test message

" diff --git a/etna/api/tests/expected_results/author.json b/etna/api/tests/expected_results/author.json index 3b8ec30d3..b74f588fd 100644 --- a/etna/api/tests/expected_results/author.json +++ b/etna/api/tests/expected_results/author.json @@ -68,7 +68,7 @@ "cascade": true, "uid": ALERT_UID }, - "type_label": "Person", + "type_label": null, "mourning_notice": { "title": "Test title", "message": "

Test message

" diff --git a/etna/api/tests/expected_results/early_modern.json b/etna/api/tests/expected_results/early_modern.json index 581c821c1..2b04d301a 100644 --- a/etna/api/tests/expected_results/early_modern.json +++ b/etna/api/tests/expected_results/early_modern.json @@ -105,7 +105,7 @@ "custom_sensitive_image": null }, "global_alert": null, - "type_label": "Time period", + "type_label": "Explore the collection", "mourning_notice": { "title": "Test title", "message": "

Test message

" diff --git a/etna/api/tests/expected_results/focused_article.json b/etna/api/tests/expected_results/focused_article.json index e63f68b61..6800e71db 100644 --- a/etna/api/tests/expected_results/focused_article.json +++ b/etna/api/tests/expected_results/focused_article.json @@ -153,7 +153,7 @@ "title": "arts", "url": "/arts/", "full_url": "http://localhost/arts/", - "type_label": "Topic", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 2, @@ -179,7 +179,7 @@ "title": "early_modern", "url": "/early_modern/", "full_url": "http://localhost/early_modern/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 4, @@ -205,7 +205,7 @@ "title": "author", "url": "/people/author/", "full_url": "http://localhost/people/author/", - "type_label": "Person", + "type_label": null, "teaser_text": "Teaser text", "teaser_image": { "id": 10, diff --git a/etna/api/tests/expected_results/highlight_gallery.json b/etna/api/tests/expected_results/highlight_gallery.json index 7fe4d7e4f..c4d3de9fb 100644 --- a/etna/api/tests/expected_results/highlight_gallery.json +++ b/etna/api/tests/expected_results/highlight_gallery.json @@ -157,7 +157,7 @@ "title": "arts", "url": "/arts/", "full_url": "http://localhost/arts/", - "type_label": "Topic", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 2, @@ -183,7 +183,7 @@ "title": "early_modern", "url": "/early_modern/", "full_url": "http://localhost/early_modern/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 4, diff --git a/etna/api/tests/expected_results/pages.json b/etna/api/tests/expected_results/pages.json index 3a492fb3f..1bde7456d 100644 --- a/etna/api/tests/expected_results/pages.json +++ b/etna/api/tests/expected_results/pages.json @@ -8,7 +8,7 @@ "title": "Home", "url": "/", "full_url": "http://localhost/", - "type_label": "Home", + "type_label": null, "teaser_text": "", "teaser_image": null }, @@ -17,7 +17,7 @@ "title": "arts", "url": "/arts/", "full_url": "http://localhost/arts/", - "type_label": "Topic", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 2, @@ -66,7 +66,7 @@ "title": "early_modern", "url": "/early_modern/", "full_url": "http://localhost/early_modern/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 4, @@ -90,7 +90,7 @@ "title": "postwar", "url": "/postwar/", "full_url": "http://localhost/postwar/", - "type_label": "Time period", + "type_label": "Explore the collection", "teaser_text": "Teaser text", "teaser_image": { "id": 6, @@ -114,7 +114,7 @@ "title": "people", "url": "/people/", "full_url": "http://localhost/people/", - "type_label": "People index", + "type_label": null, "teaser_text": "Teaser text", "teaser_image": { "id": 8, @@ -138,7 +138,7 @@ "title": "author", "url": "/people/author/", "full_url": "http://localhost/people/author/", - "type_label": "Person", + "type_label": null, "teaser_text": "Teaser text", "teaser_image": { "id": 10, @@ -203,7 +203,7 @@ "title": "article_index", "url": "/article_index/", "full_url": "http://localhost/article_index/", - "type_label": "Article index", + "type_label": null, "teaser_text": "Teaser text", "teaser_image": { "id": 11, diff --git a/etna/api/tests/expected_results/people.json b/etna/api/tests/expected_results/people.json index edeee1323..c2ccc01df 100644 --- a/etna/api/tests/expected_results/people.json +++ b/etna/api/tests/expected_results/people.json @@ -68,7 +68,7 @@ "cascade": true, "uid": ALERT_UID }, - "type_label": "People index", + "type_label": null, "mourning_notice": { "title": "Test title", "message": "

Test message

" @@ -79,7 +79,7 @@ "title": "author", "url": "/people/author/", "full_url": "http://localhost/people/author/", - "type_label": "Person", + "type_label": null, "teaser_text": "Teaser text", "teaser_image": { "id": 10, diff --git a/etna/api/tests/expected_results/postwar.json b/etna/api/tests/expected_results/postwar.json index 8fa36de3e..1332891b2 100644 --- a/etna/api/tests/expected_results/postwar.json +++ b/etna/api/tests/expected_results/postwar.json @@ -105,7 +105,7 @@ "custom_sensitive_image": null }, "global_alert": null, - "type_label": "Time period", + "type_label": "Explore the collection", "mourning_notice": { "title": "Test title", "message": "

Test message

" diff --git a/etna/blog/migrations/0002_alter_blogpostpage_options_alter_blogpostpage_body.py b/etna/blog/migrations/0002_alter_blogpostpage_options_alter_blogpostpage_body.py new file mode 100644 index 000000000..e928b398e --- /dev/null +++ b/etna/blog/migrations/0002_alter_blogpostpage_options_alter_blogpostpage_body.py @@ -0,0 +1,259 @@ +# Generated by Django 5.0.8 on 2024-10-15 10:11 +# etna:allowAlterField + +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("blog", "0001_initial"), + ] + + operations = [ + migrations.AlterModelOptions( + name="blogpostpage", + options={ + "verbose_name": "Blog post page", + "verbose_name_plural": "Blog post pages", + }, + ), + migrations.AlterField( + model_name="blogpostpage", + name="body", + field=wagtail.fields.StreamField( + [("content_section", 40)], + block_lookup={ + 0: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Heading", "max_length": 100}, + ), + 1: ("wagtail.blocks.CharBlock", (), {}), + 2: ( + "wagtail.blocks.TextBlock", + (), + {"features": ["bold", "italic", "link"], "required": False}, + ), + 3: ("wagtail.blocks.CharBlock", (), {"required": False}), + 4: ("wagtail.blocks.URLBlock", (), {"required": False}), + 5: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"required": False}, + ), + 6: ("wagtail.blocks.EmailBlock", (), {"required": False}), + 7: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link"], "required": False}, + ), + 8: ( + "wagtail.blocks.StructBlock", + [ + [ + ("title", 1), + ("address", 2), + ("telephone", 3), + ("chat_link", 4), + ("chat_note", 5), + ("email", 6), + ("website_link", 4), + ("social_media", 7), + ] + ], + {}, + ), + 9: ( + "wagtail.documents.blocks.DocumentChooserBlock", + (), + {"required": True}, + ), + 10: ("wagtail.blocks.StructBlock", [[("file", 9)]], {}), + 11: ("wagtail.blocks.ListBlock", (10,), {}), + 12: ("wagtail.blocks.StructBlock", [[("documents", 11)]], {}), + 13: ( + "etna.core.blocks.page_chooser.APIPageChooserBlock", + (), + { + "label": "Page", + "page_type": ["wagtailcore.Page"], + "required": True, + }, + ), + 14: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "Optional override for the teaser text", + "label": "Teaser text override", + "required": False, + }, + ), + 15: ( + "wagtail.blocks.StructBlock", + [[("page", 13), ("teaser_text", 14)]], + {}, + ), + 16: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + {"rendition_size": "max-900x900", "required": True}, + ), + 17: ( + "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, + }, + ), + 18: ( + "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, + }, + ), + 19: ( + "wagtail.blocks.StructBlock", + [[("image", 16), ("alt_text", 17), ("caption", 18)]], + {}, + ), + 20: ("wagtail.blocks.ListBlock", (19,), {}), + 21: ( + "wagtail.blocks.StructBlock", + [[("title", 3), ("description", 7), ("images", 20)]], + {}, + ), + 22: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "A descriptive title for the media block", + "required": True, + }, + ), + 23: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + {"help_text": "A background image for the media block"}, + ), + 24: ("etna.media.blocks.MediaChooserBlock", (), {}), + 25: ( + "wagtail.blocks.StructBlock", + [[("title", 22), ("background_image", 23), ("media", 24)]], + {}, + ), + 26: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link", "ol", "ul"]}, + ), + 27: ("wagtail.blocks.StructBlock", [[("text", 26)]], {}), + 28: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link"], "required": True}, + ), + 29: ( + "wagtail.blocks.CharBlock", + (), + {"max_length": 100, "required": False}, + ), + 30: ( + "wagtail.blocks.StructBlock", + [[("quote", 28), ("attribution", 29)]], + {}, + ), + 31: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Sub-heading", "max_length": 100}, + ), + 32: ("wagtail.blocks.StructBlock", [[("heading", 31)]], {}), + 33: ( + "wagtail.contrib.table_block.blocks.TableBlock", + (), + { + "table_options": { + "contextMenu": [ + "row_above", + "row_below", + "---------", + "col_left", + "col_right", + "---------", + "remove_row", + "remove_col", + "---------", + "undo", + "redo", + "---------", + "alignment", + ] + } + }, + ), + 34: ("wagtail.blocks.StructBlock", [[("table", 33)]], {}), + 35: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Title", "max_length": 100, "required": True}, + ), + 36: ( + "wagtail.blocks.CharBlock", + (), + { + "label": "YouTube Video ID", + "max_length": 11, + "required": True, + }, + ), + 37: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + { + "label": "Preview Image", + "rendition_size": "max-640x360", + "required": False, + }, + ), + 38: ( + "wagtail.blocks.StructBlock", + [[("title", 35), ("video_id", 36), ("preview_image", 37)]], + {}, + ), + 39: ( + "wagtail.blocks.StreamBlock", + [ + [ + ("contact", 8), + ("document", 12), + ("featured_page", 15), + ("image", 19), + ("image_gallery", 21), + ("media", 25), + ("paragraph", 27), + ("quote", 30), + ("sub_heading", 32), + ("table", 34), + ("youtube_video", 38), + ] + ], + {"required": False}, + ), + 40: ( + "wagtail.blocks.StructBlock", + [[("heading", 0), ("content", 39)]], + {}, + ), + }, + ), + ), + ] diff --git a/etna/blog/models.py b/etna/blog/models.py index 0871eafc4..97c238e4d 100644 --- a/etna/blog/models.py +++ b/etna/blog/models.py @@ -42,6 +42,8 @@ def blog_pages(self): APIField("blog_pages", serializer=DefaultPageSerializer(many=True)) ] + max_count = 1 + class BlogPage(HeroImageMixin, BasePageWithRequiredIntro): """Blog page @@ -132,3 +134,8 @@ class BlogPostPage(AuthorPageMixin, ContentWarningMixin, BasePageWithRequiredInt APIField("body"), ] ) + + class Meta: + verbose_name = "Blog post page" + verbose_name_plural = "Blog post pages" + verbose_name_public = "Blog post" diff --git a/etna/collections/models.py b/etna/collections/models.py index 3f6c7a78a..ec167a99b 100644 --- a/etna/collections/models.py +++ b/etna/collections/models.py @@ -239,7 +239,7 @@ class TopicExplorerPage(RequiredHeroImageMixin, BasePageWithRequiredIntro): class Meta: verbose_name = _("topic page") verbose_name_plural = _("topic pages") - verbose_name_public = _("topic") + verbose_name_public = _("explore the collection") featured_article = models.ForeignKey( "wagtailcore.Page", @@ -476,7 +476,7 @@ class TimePeriodExplorerPage(RequiredHeroImageMixin, BasePageWithRequiredIntro): class Meta: verbose_name = _("time period page") verbose_name_plural = _("time period pages") - verbose_name_public = _("time period") + verbose_name_public = _("explore the collection") featured_article = models.ForeignKey( "wagtailcore.Page", diff --git a/etna/cookies/models.py b/etna/cookies/models.py index d15e1093c..099a8e155 100755 --- a/etna/cookies/models.py +++ b/etna/cookies/models.py @@ -26,6 +26,5 @@ class CookieDetailsPage(BasePageWithRequiredIntro): class Meta: verbose_name = "Cookie details page" verbose_name_plural = "Cookie details pages" - verbose_name_public = "cookies" api_fields = BasePageWithRequiredIntro.api_fields + [APIField("body")] diff --git a/etna/core/blocks/promoted_links.py b/etna/core/blocks/promoted_links.py index fef1b6f60..17fa47941 100644 --- a/etna/core/blocks/promoted_links.py +++ b/etna/core/blocks/promoted_links.py @@ -155,6 +155,20 @@ class FeaturedPageBlock(blocks.StructBlock): page_type="wagtailcore.Page", ) + teaser_text = blocks.CharBlock( + label="Teaser text override", + required=False, + help_text="Optional override for the teaser text", + ) + + def get_api_representation(self, value, context=None): + representation = super().get_api_representation(value, context) + if value.get("page"): + if value.get("teaser_text"): + representation["page"]["teaser_text"] = value.get("teaser_text") + del representation["teaser_text"] + return representation + class Meta: icon = "doc-full" label = "Featured page" diff --git a/etna/core/models/basepage.py b/etna/core/models/basepage.py index b79d2cfe4..384064e28 100644 --- a/etna/core/models/basepage.py +++ b/etna/core/models/basepage.py @@ -105,12 +105,8 @@ def type_label(cls) -> str: with the first letter capitalized for display. """ if cls.has_custom_type_label(): - label = cls._meta.verbose_name_public - else: - label = cls._meta.verbose_name - if label.lower().endswith(" page"): - label = label[:-5] - return capfirst(label) + return capfirst(cls._meta.verbose_name_public) + return None @classmethod def has_custom_type_label(cls) -> bool: diff --git a/etna/generic_pages/migrations/0036_alter_generalpage_body.py b/etna/generic_pages/migrations/0036_alter_generalpage_body.py new file mode 100644 index 000000000..3b624fb21 --- /dev/null +++ b/etna/generic_pages/migrations/0036_alter_generalpage_body.py @@ -0,0 +1,565 @@ +# Generated by Django 5.0.8 on 2024-10-14 15:55 +# etna:allowAlterField + +import etna.records.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("generic_pages", "0035_alter_generalpage_body"), + ] + + operations = [ + migrations.AlterField( + model_name="generalpage", + name="body", + field=wagtail.fields.StreamField( + [ + ("accordions", 10), + ("button", 15), + ("call_to_action", 17), + ("contact", 23), + ("description_list", 27), + ("details", 28), + ("document", 6), + ("do_dont_list", 33), + ("featured_page", 36), + ("featured_record_article", 38), + ("image", 42), + ("image_gallery", 44), + ("inset_text", 46), + ("media", 50), + ("paragraph", 46), + ("promoted_item", 62), + ("promoted_list", 69), + ("quote", 72), + ("record_links", 74), + ("table", 76), + ("warning_text", 77), + ("youtube_video", 81), + ("content_section", 88), + ], + blank=True, + block_lookup={ + 0: ("wagtail.blocks.CharBlock", (), {"required": True}), + 1: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + { + "features": ["bold", "italic", "link", "ol", "ul"], + "required": True, + }, + ), + 2: ("wagtail.contrib.table_block.blocks.TableBlock", (), {}), + 3: ( + "wagtail.documents.blocks.DocumentChooserBlock", + (), + {"required": True}, + ), + 4: ("wagtail.blocks.StructBlock", [[("file", 3)]], {}), + 5: ("wagtail.blocks.ListBlock", (4,), {}), + 6: ("wagtail.blocks.StructBlock", [[("documents", 5)]], {}), + 7: ( + "wagtail.blocks.StreamBlock", + [[("text", 1), ("table", 2), ("documents", 6)]], + {}, + ), + 8: ( + "wagtail.blocks.StructBlock", + [[("title", 0), ("body", 7)]], + {}, + ), + 9: ("wagtail.blocks.ListBlock", (8,), {}), + 10: ("wagtail.blocks.StructBlock", [[("items", 9)]], {}), + 11: ("wagtail.blocks.CharBlock", (), {}), + 12: ( + "etna.core.blocks.page_chooser.APIPageChooserBlock", + (), + {"required": False}, + ), + 13: ("wagtail.blocks.URLBlock", (), {"required": False}), + 14: ( + "wagtail.blocks.BooleanBlock", + (), + { + "help_text": "Use the accented button style", + "label": "Accented", + "required": False, + }, + ), + 15: ( + "wagtail.blocks.StructBlock", + [ + [ + ("label", 11), + ("link", 12), + ("external_link", 13), + ("accented", 14), + ] + ], + {}, + ), + 16: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + { + "features": ["bold", "italic", "link", "ol", "ul"], + "max_length": 100, + }, + ), + 17: ( + "wagtail.blocks.StructBlock", + [[("body", 16), ("button", 15)]], + {}, + ), + 18: ( + "wagtail.blocks.TextBlock", + (), + {"features": ["bold", "italic", "link"], "required": False}, + ), + 19: ("wagtail.blocks.CharBlock", (), {"required": False}), + 20: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"required": False}, + ), + 21: ("wagtail.blocks.EmailBlock", (), {"required": False}), + 22: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link"], "required": False}, + ), + 23: ( + "wagtail.blocks.StructBlock", + [ + [ + ("title", 11), + ("address", 18), + ("telephone", 19), + ("chat_link", 13), + ("chat_note", 20), + ("email", 21), + ("website_link", 13), + ("social_media", 22), + ] + ], + {}, + ), + 24: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link"]}, + ), + 25: ( + "wagtail.blocks.StructBlock", + [[("term", 0), ("detail", 24)]], + {}, + ), + 26: ("wagtail.blocks.ListBlock", (25,), {}), + 27: ("wagtail.blocks.StructBlock", [[("items", 26)]], {}), + 28: ( + "wagtail.blocks.StructBlock", + [[("title", 0), ("body", 1)]], + {}, + ), + 29: ( + "wagtail.blocks.StructBlock", + [[("text", 24)]], + {"icon": "check", "label": "Do item"}, + ), + 30: ("wagtail.blocks.ListBlock", (29,), {"label": "Dos"}), + 31: ( + "wagtail.blocks.StructBlock", + [[("text", 24)]], + {"icon": "cross", "label": "Don't item"}, + ), + 32: ("wagtail.blocks.ListBlock", (31,), {"label": "Don'ts"}), + 33: ( + "wagtail.blocks.StructBlock", + [[("do", 30), ("dont", 32)]], + {}, + ), + 34: ( + "etna.core.blocks.page_chooser.APIPageChooserBlock", + (), + { + "label": "Page", + "page_type": ["wagtailcore.Page"], + "required": True, + }, + ), + 35: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "Optional override for the teaser text", + "label": "Teaser text override", + "required": False, + }, + ), + 36: ( + "wagtail.blocks.StructBlock", + [[("page", 34), ("teaser_text", 35)]], + {}, + ), + 37: ( + "etna.core.blocks.page_chooser.APIPageChooserBlock", + (), + { + "label": "Page", + "page_type": ["articles.RecordArticlePage"], + "required_api_fields": ["teaser_image"], + }, + ), + 38: ("wagtail.blocks.StructBlock", [[("page", 37)]], {}), + 39: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + {"rendition_size": "max-900x900", "required": True}, + ), + 40: ( + "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, + }, + ), + 41: ( + "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, + }, + ), + 42: ( + "wagtail.blocks.StructBlock", + [[("image", 39), ("alt_text", 40), ("caption", 41)]], + {}, + ), + 43: ("wagtail.blocks.ListBlock", (42,), {}), + 44: ( + "wagtail.blocks.StructBlock", + [[("title", 19), ("description", 22), ("images", 43)]], + {}, + ), + 45: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link", "ol", "ul"]}, + ), + 46: ("wagtail.blocks.StructBlock", [[("text", 45)]], {}), + 47: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "A descriptive title for the media block", + "required": True, + }, + ), + 48: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + {"help_text": "A background image for the media block"}, + ), + 49: ("etna.media.blocks.MediaChooserBlock", (), {}), + 50: ( + "wagtail.blocks.StructBlock", + [[("title", 47), ("background_image", 48), ("media", 49)]], + {}, + ), + 51: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "Title of the promoted page", + "label": "Title", + "max_length": 100, + }, + ), + 52: ( + "wagtail.blocks.ChoiceBlock", + [], + { + "choices": [ + ("blog", "Blog post"), + ("podcast", "Podcast"), + ("video", "Video"), + ("video-external", "External video"), + ("external-link", "External link"), + ], + "label": "Category", + }, + ), + 53: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "This is a free text field. Please enter date as per agreed format: 14 April 2021", + "required": False, + }, + ), + 54: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "Podcast or video duration.", + "label": "Duration", + "max_length": 50, + "required": False, + }, + ), + 55: ( + "wagtail.blocks.URLBlock", + (), + { + "help_text": "URL for the external page", + "label": "External URL", + }, + ), + 56: ( + "wagtail.blocks.BooleanBlock", + (), + { + "label": "Should this URL open in a new tab?

Tick the box if 'yes'

", + "required": False, + }, + ), + 57: ( + "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, + }, + ), + 58: ( + "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, + }, + ), + 59: ( + "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, + }, + ), + 60: ( + "wagtail.blocks.StructBlock", + [[("image", 39), ("decorative", 58), ("alt_text", 59)]], + { + "label": "Teaser image", + "template": "articles/blocks/images/blog-embed__image-container.html", + }, + ), + 61: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + { + "features": ["bold", "italic", "link"], + "help_text": "A description of the promoted page", + }, + ), + 62: ( + "wagtail.blocks.StructBlock", + [ + [ + ("title", 51), + ("category", 52), + ("publication_date", 53), + ("author", 19), + ("duration", 54), + ("url", 55), + ("target_blank", 56), + ("cta_label", 57), + ("image", 60), + ("description", 61), + ] + ], + {}, + ), + 63: ( + "wagtail.snippets.blocks.SnippetChooserBlock", + ("categories.Category",), + {}, + ), + 64: ( + "wagtail.blocks.CharBlock", + (), + { + "help_text": "The title of the target page", + "max_length": 100, + "required": True, + }, + ), + 65: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + { + "features": ["bold", "italic", "link"], + "help_text": "A description of the target page", + "required": False, + }, + ), + 66: ("wagtail.blocks.URLBlock", (), {"required": True}), + 67: ( + "wagtail.blocks.StructBlock", + [[("title", 64), ("description", 65), ("url", 66)]], + {}, + ), + 68: ("wagtail.blocks.ListBlock", (67,), {}), + 69: ( + "wagtail.blocks.StructBlock", + [[("category", 63), ("summary", 22), ("promoted_items", 68)]], + {}, + ), + 70: ( + "etna.core.blocks.paragraph.APIRichTextBlock", + (), + {"features": ["bold", "italic", "link"], "required": True}, + ), + 71: ( + "wagtail.blocks.CharBlock", + (), + {"max_length": 100, "required": False}, + ), + 72: ( + "wagtail.blocks.StructBlock", + [[("quote", 70), ("attribution", 71)]], + {}, + ), + 73: ( + "wagtail.blocks.ListBlock", + (etna.records.blocks.RecordLinkBlock,), + {"label": "Items"}, + ), + 74: ("wagtail.blocks.StructBlock", [[("items", 73)]], {}), + 75: ( + "wagtail.contrib.table_block.blocks.TableBlock", + (), + { + "table_options": { + "contextMenu": [ + "row_above", + "row_below", + "---------", + "col_left", + "col_right", + "---------", + "remove_row", + "remove_col", + "---------", + "undo", + "redo", + "---------", + "alignment", + ] + } + }, + ), + 76: ("wagtail.blocks.StructBlock", [[("table", 75)]], {}), + 77: ("wagtail.blocks.StructBlock", [[("body", 45)]], {}), + 78: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Title", "max_length": 100, "required": True}, + ), + 79: ( + "wagtail.blocks.CharBlock", + (), + { + "label": "YouTube Video ID", + "max_length": 11, + "required": True, + }, + ), + 80: ( + "etna.core.blocks.image.APIImageChooserBlock", + (), + { + "label": "Preview Image", + "rendition_size": "max-640x360", + "required": False, + }, + ), + 81: ( + "wagtail.blocks.StructBlock", + [[("title", 78), ("video_id", 79), ("preview_image", 80)]], + {}, + ), + 82: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Heading", "max_length": 100}, + ), + 83: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Sub-heading", "max_length": 100}, + ), + 84: ("wagtail.blocks.StructBlock", [[("heading", 83)]], {}), + 85: ( + "wagtail.blocks.CharBlock", + (), + {"label": "Sub-sub-heading", "max_length": 100}, + ), + 86: ("wagtail.blocks.StructBlock", [[("heading", 85)]], {}), + 87: ( + "wagtail.blocks.StreamBlock", + [ + [ + ("accordions", 10), + ("button", 15), + ("call_to_action", 17), + ("contact", 23), + ("description_list", 27), + ("details", 28), + ("document", 6), + ("do_dont_list", 33), + ("featured_page", 36), + ("featured_record_article", 38), + ("image", 42), + ("image_gallery", 44), + ("inset_text", 46), + ("media", 50), + ("paragraph", 46), + ("promoted_item", 62), + ("promoted_list", 69), + ("quote", 72), + ("record_links", 74), + ("sub_heading", 84), + ("sub_sub_heading", 86), + ("table", 76), + ("warning_text", 77), + ("youtube_video", 81), + ] + ], + {"required": False}, + ), + 88: ( + "wagtail.blocks.StructBlock", + [[("heading", 82), ("content", 87)]], + {}, + ), + }, + null=True, + ), + ), + ] diff --git a/etna/home/models.py b/etna/home/models.py index 2b64a679e..c4344100a 100755 --- a/etna/home/models.py +++ b/etna/home/models.py @@ -44,3 +44,5 @@ class HomePage(BasePageWithRequiredIntro): api_fields = BasePageWithRequiredIntro.api_fields + [ APIField("body"), ] + + max_count = 1 diff --git a/etna/people/models.py b/etna/people/models.py index 5a93acaeb..915310b97 100644 --- a/etna/people/models.py +++ b/etna/people/models.py @@ -137,7 +137,6 @@ class PersonPage(BasePage): class Meta: verbose_name = "Person page" verbose_name_plural = "People pages" - verbose_name_public = "person" # DataLayerMixin overrides gtm_content_group = "Person page" diff --git a/etna/search/forms.py b/etna/search/forms.py index af1e6b0b4..44f085c12 100644 --- a/etna/search/forms.py +++ b/etna/search/forms.py @@ -335,7 +335,10 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["format"].choices = [ - (model._meta.label_lower, model.type_label()) + ( + model._meta.label_lower, + model.type_label() or model._meta.verbose_name.lower()[:-5], + ) for model in get_page_models() if issubclass(model, BasePage) and not model._meta.abstract ] diff --git a/etna/search/views.py b/etna/search/views.py index 75e445129..3113831cc 100755 --- a/etna/search/views.py +++ b/etna/search/views.py @@ -956,7 +956,7 @@ def get_results( page_type_filters.append( ( model._meta.label_lower, - f"Format: {model.type_label()}", + f"Format: {model.type_label() or model._meta.verbose_name.lower()[:-5]}", ) ) self.selected_filters["format"] = sorted(