From 12914f536d7785b6429c3de56927e2b9735226c4 Mon Sep 17 00:00:00 2001 From: Rachell Calhoun Date: Wed, 3 Apr 2024 17:34:12 -0400 Subject: [PATCH] 372 Add Image Card Blocks (#381) * add precom remove migrations * fix migrations --- home/blocks.py | 20 ++ ...ter_generalpage_content_vert_image_card.py | 304 ++++++++++++++++++ ...07_alter_entrypage_body_vert_image_card.py | 303 +++++++++++++++++ home/templates/home/general_page.html | 2 +- .../blocks/vertical_image_cards_block.html | 26 ++ indymeet/templates/puput/entry_page.html | 2 +- 6 files changed, 655 insertions(+), 2 deletions(-) create mode 100644 home/migrations/0028_alter_generalpage_content_vert_image_card.py create mode 100644 home/puput_migrations/0007_alter_entrypage_body_vert_image_card.py create mode 100644 indymeet/templates/blocks/vertical_image_cards_block.html diff --git a/home/blocks.py b/home/blocks.py index a528f476..954f8bd8 100644 --- a/home/blocks.py +++ b/home/blocks.py @@ -186,6 +186,25 @@ class Meta: template = "blocks/caption.html" +class VerticalImageCardBlock(blocks.StreamBlock): + images = blocks.StructBlock( + [ + ("image", ImageChooserBlock(required=True, help_text="size: 800X450px")), + ("caption", CustomCaption()), + ( + "description", + blocks.CharBlock( + max_length=300, required=False, help_text="300 characters limit" + ), + ), + ("link", blocks.URLBlock(required=False)), + ] + ) + + class Meta: + template = "blocks/vertical_image_cards_block.html" + + class RichTextBlock(blocks.StructBlock): text = blocks.RichTextBlock( max_length=10000, @@ -224,3 +243,4 @@ class BaseStreamBlock(blocks.StreamBlock): video_embed = VideoEmbed() table = CustomTableBlock() code_block = CodeBlock() + vertical_image_cards = VerticalImageCardBlock() diff --git a/home/migrations/0028_alter_generalpage_content_vert_image_card.py b/home/migrations/0028_alter_generalpage_content_vert_image_card.py new file mode 100644 index 00000000..b16e77b0 --- /dev/null +++ b/home/migrations/0028_alter_generalpage_content_vert_image_card.py @@ -0,0 +1,304 @@ +# Generated by Django 4.1.13 on 2024-04-03 21:30 +from __future__ import annotations + +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations + +import home.blocks + + +class Migration(migrations.Migration): + dependencies = [ + ("home", "0027_alter_generalpage_content_optional_fields"), + ] + + operations = [ + migrations.AlterField( + model_name="generalpage", + name="content", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.StructBlock( + [ + ( + "size", + wagtail.blocks.ChoiceBlock( + choices=[ + ("text-5xl", "h1"), + ("text-4xl", "h2"), + ("text-3xl", "h3"), + ("text-2xl", "h4"), + ("text-xl", "h5"), + ("text-lg", "h6"), + ], + icon="title", + ), + ), + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", max_length=255 + ), + ), + ], + icon="h1", + label="Heading", + ), + ), + ( + "rich_text", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.RichTextBlock( + features=[ + "embed", + "bold", + "italic", + "link", + "superscript", + "subscript", + "strikethrough", + "code", + "hr", + ], + icon="title", + label="Rich Text", + max_length=10000, + ), + ) + ] + ), + ), + ( + "list", + wagtail.blocks.StructBlock( + [ + ( + "size", + wagtail.blocks.ChoiceBlock( + choices=[ + ("circle", "unordered list"), + ("decimal", "ordered list"), + ("none", "unstyled"), + ] + ), + ), + ( + "text", + wagtail.blocks.RichTextBlock( + features=["ul"], icon="list-ol" + ), + ), + ], + icon="list-ol", + label="List", + ), + ), + ("paragraph", wagtail.blocks.TextBlock(max_length=10000)), + ( + "html", + wagtail.blocks.RawHTMLBlock(icon="code", label="Raw HTML"), + ), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "caption", + wagtail.blocks.StructBlock( + [("text", wagtail.blocks.TextBlock())] + ), + ), + ( + "text_with_heading", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", max_length=255 + ), + ), + ("text", wagtail.blocks.TextBlock()), + ] + ), + ), + ( + "text_with_heading_and_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + max_length=255, required=False + ), + ), + ("text", wagtail.blocks.TextBlock(required=False)), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "text_with_heading_and_right_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", + max_length=255, + required=False, + ), + ), + ("text", wagtail.blocks.TextBlock()), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "text_with_heading_and_left_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="blog", + max_length=255, + required=False, + ), + ), + ("text", wagtail.blocks.TextBlock()), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "left_quote_right_image", + wagtail.blocks.StructBlock( + [ + ("quote", wagtail.blocks.TextBlock()), + ("byline", wagtail.blocks.CharBlock(max_length=255)), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ], + icon="openquote", + ), + ), + ( + "video_embed", + wagtail.blocks.StructBlock( + [ + ("heading", wagtail.blocks.CharBlock(max_length=255)), + ("text", wagtail.blocks.TextBlock()), + ] + ), + ), + ("table", home.blocks.CustomTableBlock()), + ( + "code_block", + wagtail.blocks.StructBlock( + [ + ( + "language", + wagtail.blocks.ChoiceBlock( + choices=[ + ("Python", "python"), + ("Markup", "html"), + ("CSS", "css"), + ("Clojure", "clojure"), + ("Bash", "shell"), + ("Django", "django"), + ("Jinja2", "jinja2"), + ("Docker", "dockerfile"), + ("Git", "git"), + ("GraphQL", "graphql"), + ("Handlebars", "handlebars"), + (".ignore", "gitignore"), + ("JSON", "json"), + ("JSON5", "json5"), + ("Markdown", "md"), + ("Markdown", "md"), + ("React JSX", "jsx"), + ("React TSX", "tsx"), + ("SASS", "sass"), + ("SCSS", "scss"), + ("TypeScript", "ts"), + ("vim", "vim"), + ] + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + blank=True, max_length=255 + ), + ), + ( + "page", + wagtail.blocks.CharBlock( + blank=True, max_length=255 + ), + ), + ( + "code", + wagtail.blocks.TextBlock( + blank=True, max_length=1000 + ), + ), + ] + ), + ), + ( + "vertical_image_cards", + wagtail.blocks.StreamBlock( + [ + ( + "images", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + help_text="size: 800X450px", + required=True, + ), + ), + ( + "caption", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.TextBlock(), + ) + ] + ), + ), + ( + "description", + wagtail.blocks.CharBlock( + help_text="300 characters limit", + max_length=300, + required=False, + ), + ), + ( + "link", + wagtail.blocks.URLBlock(required=False), + ), + ] + ), + ) + ] + ), + ), + ], + blank=True, + null=True, + use_json_field=True, + verbose_name="StreamField Body", + ), + ), + ] diff --git a/home/puput_migrations/0007_alter_entrypage_body_vert_image_card.py b/home/puput_migrations/0007_alter_entrypage_body_vert_image_card.py new file mode 100644 index 00000000..2347cdaa --- /dev/null +++ b/home/puput_migrations/0007_alter_entrypage_body_vert_image_card.py @@ -0,0 +1,303 @@ +# Generated by Django 4.1.13 on 2024-04-03 21:30 +from __future__ import annotations + +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations + +import home.blocks + + +class Migration(migrations.Migration): + dependencies = [ + ("puput", "0006_alter_entrypage_body_optional_fields"), + ] + + operations = [ + migrations.AlterField( + model_name="entrypage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.StructBlock( + [ + ( + "size", + wagtail.blocks.ChoiceBlock( + choices=[ + ("text-5xl", "h1"), + ("text-4xl", "h2"), + ("text-3xl", "h3"), + ("text-2xl", "h4"), + ("text-xl", "h5"), + ("text-lg", "h6"), + ], + icon="title", + ), + ), + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", max_length=255 + ), + ), + ], + icon="h1", + label="Heading", + ), + ), + ( + "rich_text", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.RichTextBlock( + features=[ + "embed", + "bold", + "italic", + "link", + "superscript", + "subscript", + "strikethrough", + "code", + "hr", + ], + icon="title", + label="Rich Text", + max_length=10000, + ), + ) + ] + ), + ), + ( + "list", + wagtail.blocks.StructBlock( + [ + ( + "size", + wagtail.blocks.ChoiceBlock( + choices=[ + ("circle", "unordered list"), + ("decimal", "ordered list"), + ("none", "unstyled"), + ] + ), + ), + ( + "text", + wagtail.blocks.RichTextBlock( + features=["ul"], icon="list-ol" + ), + ), + ], + icon="list-ol", + label="List", + ), + ), + ("paragraph", wagtail.blocks.TextBlock(max_length=10000)), + ( + "html", + wagtail.blocks.RawHTMLBlock(icon="code", label="Raw HTML"), + ), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "caption", + wagtail.blocks.StructBlock( + [("text", wagtail.blocks.TextBlock())] + ), + ), + ( + "text_with_heading", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", max_length=255 + ), + ), + ("text", wagtail.blocks.TextBlock()), + ] + ), + ), + ( + "text_with_heading_and_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + max_length=255, required=False + ), + ), + ("text", wagtail.blocks.TextBlock(required=False)), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "text_with_heading_and_right_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="heading-blog", + max_length=255, + required=False, + ), + ), + ("text", wagtail.blocks.TextBlock()), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "text_with_heading_and_left_image", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + class_name="blog", + max_length=255, + required=False, + ), + ), + ("text", wagtail.blocks.TextBlock()), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ] + ), + ), + ( + "left_quote_right_image", + wagtail.blocks.StructBlock( + [ + ("quote", wagtail.blocks.TextBlock()), + ("byline", wagtail.blocks.CharBlock(max_length=255)), + ("image", wagtail.images.blocks.ImageChooserBlock()), + ], + icon="openquote", + ), + ), + ( + "video_embed", + wagtail.blocks.StructBlock( + [ + ("heading", wagtail.blocks.CharBlock(max_length=255)), + ("text", wagtail.blocks.TextBlock()), + ] + ), + ), + ("table", home.blocks.CustomTableBlock()), + ( + "code_block", + wagtail.blocks.StructBlock( + [ + ( + "language", + wagtail.blocks.ChoiceBlock( + choices=[ + ("Python", "python"), + ("Markup", "html"), + ("CSS", "css"), + ("Clojure", "clojure"), + ("Bash", "shell"), + ("Django", "django"), + ("Jinja2", "jinja2"), + ("Docker", "dockerfile"), + ("Git", "git"), + ("GraphQL", "graphql"), + ("Handlebars", "handlebars"), + (".ignore", "gitignore"), + ("JSON", "json"), + ("JSON5", "json5"), + ("Markdown", "md"), + ("Markdown", "md"), + ("React JSX", "jsx"), + ("React TSX", "tsx"), + ("SASS", "sass"), + ("SCSS", "scss"), + ("TypeScript", "ts"), + ("vim", "vim"), + ] + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + blank=True, max_length=255 + ), + ), + ( + "page", + wagtail.blocks.CharBlock( + blank=True, max_length=255 + ), + ), + ( + "code", + wagtail.blocks.TextBlock( + blank=True, max_length=1000 + ), + ), + ] + ), + ), + ( + "vertical_image_cards", + wagtail.blocks.StreamBlock( + [ + ( + "images", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + help_text="size: 800X450px", + required=True, + ), + ), + ( + "caption", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.TextBlock(), + ) + ] + ), + ), + ( + "description", + wagtail.blocks.CharBlock( + help_text="300 characters limit", + max_length=300, + required=False, + ), + ), + ( + "link", + wagtail.blocks.URLBlock(required=False), + ), + ] + ), + ) + ] + ), + ), + ], + null=True, + use_json_field=True, + verbose_name="StreamField Body", + ), + ), + ] diff --git a/home/templates/home/general_page.html b/home/templates/home/general_page.html index 95cd3a25..65c39377 100644 --- a/home/templates/home/general_page.html +++ b/home/templates/home/general_page.html @@ -6,7 +6,7 @@ {% block content %}
-
+

{{ page.title }} diff --git a/indymeet/templates/blocks/vertical_image_cards_block.html b/indymeet/templates/blocks/vertical_image_cards_block.html new file mode 100644 index 00000000..c9266b31 --- /dev/null +++ b/indymeet/templates/blocks/vertical_image_cards_block.html @@ -0,0 +1,26 @@ +{% load wagtailcore_tags wagtailimages_tags %} +
+{% for child in self %} +
+ {% if child.value.link %} + + {% endif %} + {% image child.value.image fill-800x450-c100 as image %} +
+ {{ child.value.image.title }} +
+ {% if child.value.link %} +
+ {% endif %} +
+
{{ child.value.caption.text }}
+

+ {{ child.value.description }} +

+
+
+
+
+{% endfor %} + +
diff --git a/indymeet/templates/puput/entry_page.html b/indymeet/templates/puput/entry_page.html index 6a4edcfd..f4ffdade 100644 --- a/indymeet/templates/puput/entry_page.html +++ b/indymeet/templates/puput/entry_page.html @@ -43,7 +43,7 @@ {% block content %}
-
{% include 'puput/entry_page_header.html' with entry=self %}