From 3e587a12a4306c93209e96d3dbdc67549bfaba53 Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Wed, 16 Nov 2022 15:38:22 +0000 Subject: [PATCH 1/6] Add basic block outline --- app/models/wagtail/blocks.py | 16 ++++++++++++++++ app/models/wagtail/pages.py | 1 + .../app/blocks/title_text_image_block.html | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/templates/app/blocks/title_text_image_block.html diff --git a/app/models/wagtail/blocks.py b/app/models/wagtail/blocks.py index aefcd5d..9e6d9ba 100644 --- a/app/models/wagtail/blocks.py +++ b/app/models/wagtail/blocks.py @@ -177,6 +177,22 @@ def link(self, *args, **kwargs): return None +class TitleTextImageBlock(blocks.StructBlock): + class Meta: + template = "app/blocks/title_text_image_block.html" + help_text = "A title, a block of text, two links and a image on the left or right hand side" + + title = blocks.CharBlock(required=True, help_text="The title of the block") + description = blocks.CharBlock( + required=True, help_text="A description displayed under the title" + ) + image = ImageChooserBlock( + required=True, + help_text="An image, displayed on the left or right of the title and description", + ) + links = blocks.ListBlock(LinkBlock()) + + class TaskManagerProjectBlock(blocks.StructBlock): class Meta: template = "app/blocks/dummy_block.html" diff --git a/app/models/wagtail/pages.py b/app/models/wagtail/pages.py index a3435e4..cece154 100644 --- a/app/models/wagtail/pages.py +++ b/app/models/wagtail/pages.py @@ -165,6 +165,7 @@ class Meta: ("html", app_blocks.HTMLBlock()), ("heading_and_subheading", app_blocks.HeadingAndSubHeadingBlock()), ("partner_logos", app_blocks.PartnerLogos()), + ("title_text_image", app_blocks.TitleTextImageBlock()), ], null=True, blank=True, diff --git a/app/templates/app/blocks/title_text_image_block.html b/app/templates/app/blocks/title_text_image_block.html new file mode 100644 index 0000000..68e5a79 --- /dev/null +++ b/app/templates/app/blocks/title_text_image_block.html @@ -0,0 +1,14 @@ +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +
+
+
{{ value.title }}
+
{{ value.description }}
+
+ {% for link in value.links %} + {% firstof link.label link.page.title %} + {% endfor %} +
+
+
{% image value.image width-200 %}
+
From 6a88e7afd220c8b83ed3eadbca6f1aa26c72cf07 Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Wed, 16 Nov 2022 16:19:48 +0000 Subject: [PATCH 2/6] Block styling --- .../app/blocks/title_text_image_block.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/templates/app/blocks/title_text_image_block.html b/app/templates/app/blocks/title_text_image_block.html index 68e5a79..09da65c 100644 --- a/app/templates/app/blocks/title_text_image_block.html +++ b/app/templates/app/blocks/title_text_image_block.html @@ -1,14 +1,19 @@ {% load wagtailcore_tags %} {% load wagtailimages_tags %} -
+
-
{{ value.title }}
-
{{ value.description }}
-
+
+

{{ value.title }}

+

{{ value.description }}

+
+
+
{% image value.image width-200 %}
-
+ From 21020227549d911789d0f08fbced5a4adfe821c2 Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Wed, 16 Nov 2022 17:08:25 +0000 Subject: [PATCH 3/6] Styling of image --- app/templates/app/blocks/title_text_image_block.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/templates/app/blocks/title_text_image_block.html b/app/templates/app/blocks/title_text_image_block.html index 09da65c..0f4a2db 100644 --- a/app/templates/app/blocks/title_text_image_block.html +++ b/app/templates/app/blocks/title_text_image_block.html @@ -1,8 +1,8 @@ {% load wagtailcore_tags %} {% load wagtailimages_tags %}
-
-
+
+

{{ value.title }}

{{ value.description }}

@@ -15,5 +15,8 @@

{{ value.ti {% endfor %}

-
{% image value.image width-200 %}
+ {% image value.image height-608 as img %} +
+
From 1944ceec9458f891c4f68f617ecdea830b120854 Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Mon, 21 Nov 2022 12:38:54 +0000 Subject: [PATCH 4/6] Further add to the block --- app/templates/app/blocks/title_text_image_block.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/templates/app/blocks/title_text_image_block.html b/app/templates/app/blocks/title_text_image_block.html index 0f4a2db..bdd94e3 100644 --- a/app/templates/app/blocks/title_text_image_block.html +++ b/app/templates/app/blocks/title_text_image_block.html @@ -1,8 +1,8 @@ {% load wagtailcore_tags %} {% load wagtailimages_tags %} -
-
-
+
+
+

{{ value.title }}

{{ value.description }}

@@ -16,7 +16,7 @@

{{ value.ti

{% image value.image height-608 as img %} -
From 5466bd36a9f11c11d8235d4425ca4d364317047d Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Mon, 21 Nov 2022 15:21:20 +0000 Subject: [PATCH 5/6] Add image right and left toggle --- app/models/wagtail/blocks.py | 8 ++++++++ app/templates/app/blocks/title_text_image_block.html | 6 +++--- app/templates/app/static_page.html | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/wagtail/blocks.py b/app/models/wagtail/blocks.py index 9e6d9ba..b030ee6 100644 --- a/app/models/wagtail/blocks.py +++ b/app/models/wagtail/blocks.py @@ -192,6 +192,14 @@ class Meta: ) links = blocks.ListBlock(LinkBlock()) + layout = blocks.ChoiceBlock( + choices=[ + ("image_right", "Image right"), + ("image_left", "Image left"), + ], + default="image_left", + ) + class TaskManagerProjectBlock(blocks.StructBlock): class Meta: diff --git a/app/templates/app/blocks/title_text_image_block.html b/app/templates/app/blocks/title_text_image_block.html index bdd94e3..bc47a02 100644 --- a/app/templates/app/blocks/title_text_image_block.html +++ b/app/templates/app/blocks/title_text_image_block.html @@ -1,6 +1,6 @@ {% load wagtailcore_tags %} {% load wagtailimages_tags %} -
+

{{ value.title }}

@@ -15,8 +15,8 @@

{{ value.ti {% endfor %}

- {% image value.image height-608 as img %} -
diff --git a/app/templates/app/static_page.html b/app/templates/app/static_page.html index f1c27c2..f55c3b2 100644 --- a/app/templates/app/static_page.html +++ b/app/templates/app/static_page.html @@ -30,7 +30,7 @@ {% endif %} {% comment %} Page content {% endcomment %} -
+
{% if page.show_header is not False %}
From 2900f57d72db0daee6536674848a1491382f8c23 Mon Sep 17 00:00:00 2001 From: Alex Andrews Date: Mon, 21 Nov 2022 15:23:25 +0000 Subject: [PATCH 6/6] Remove temporary jacking of page template to make layout checks easier --- app/templates/app/static_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/static_page.html b/app/templates/app/static_page.html index f55c3b2..f1c27c2 100644 --- a/app/templates/app/static_page.html +++ b/app/templates/app/static_page.html @@ -30,7 +30,7 @@ {% endif %} {% comment %} Page content {% endcomment %} -
+
{% if page.show_header is not False %}