From 57e30e6217f585cc8d90698eef7fe2ad366c91de Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 7 Jul 2022 11:27:38 +0200 Subject: [PATCH 01/14] WIP: dirty hack to add table to content (not working) --- publichealth/home/models/models.py | 35 ++++++++++++++++++- .../home/templates/home/page_content.html | 11 +++++- publichealth/settings/base.py | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index de655aa..725edcd 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -17,6 +17,7 @@ from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePane from wagtail.images.blocks import ImageChooserBlock from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index +from wagtail.contrib.table_block.blocks import TableBlock from puput.models import EntryPage, BlogPage from feedler.models import Entry, Stream @@ -49,6 +50,15 @@ class ArticleIndexPage(Page): 'intro_en', ) + table_en = TableBlock() + table_fr = TableBlock() + table_de = TableBlock() + trans_table = TranslatedField( + 'table_de', + 'table_fr', + 'table_en', + ) + subscribe_label_de = models.CharField("Button Label (de)", default='', blank=True, max_length=250) subscribe_label_fr = models.CharField("Button Label (fr)", default='', blank=True, max_length=250) subscribe_label_en = models.CharField("Button Label (en)", default='', blank=True, max_length=250) @@ -73,6 +83,9 @@ class ArticleIndexPage(Page): FieldPanel('intro_fr'), FieldPanel('title_en'), FieldPanel('intro_en'), + #FieldPanel('table_en'), + #FieldPanel('table_fr'), + #FieldPanel('table_de'), ImageChooserPanel('feed_image'), MultiFieldPanel( [ @@ -168,6 +181,14 @@ class ArticlePage(Page): 'body_fr', 'body_en', ) + table_en = TableBlock() + table_fr = TableBlock() + table_de = TableBlock() + trans_table = TranslatedField( + 'table_en', + 'table_fr', + 'table_de', + ) date = models.DateField("Date", null=True, blank=True) @@ -261,6 +282,15 @@ class HomePage(Page): 'body_en', ) + #table_en = TableBlock() + #table_fr = TableBlock() + #table_de = TableBlock() + #trans_table = TranslatedField( + # 'table_en', + # 'table_fr', + # 'table_de', + #) + infos_de = StreamField([ ('info', InfoBlock()) ], null=True, blank=True) @@ -275,24 +305,27 @@ class HomePage(Page): 'infos_fr', 'infos_en', ) - +# content_table = StreamField(TableBlock(), verbose_name=_('Content Table'), blank=True) content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('intro_de', classname="full"), FieldPanel('body_de', classname="full"), StreamFieldPanel('infos_de'), + #StreamFieldPanel('table_de'), ], heading="Deutsch", classname="collapsible collapsed"), MultiFieldPanel([ FieldPanel('intro_fr', classname="full"), FieldPanel('body_fr', classname="full"), StreamFieldPanel('infos_fr'), + #StreamFieldPanel('table_fr'), ], heading="Français", classname="collapsible collapsed"), MultiFieldPanel([ FieldPanel('intro_en', classname="full"), FieldPanel('body_en', classname="full"), StreamFieldPanel('infos_en'), + #StreamFieldPanel('table_fr'), ], heading="English", classname="collapsible collapsed"), ] diff --git a/publichealth/home/templates/home/page_content.html b/publichealth/home/templates/home/page_content.html index a2c4165..a2cb8a1 100644 --- a/publichealth/home/templates/home/page_content.html +++ b/publichealth/home/templates/home/page_content.html @@ -27,10 +27,19 @@

{% include_block block %}

- {% endif %} + {% endfor %} + +
+{% for block in page.trans_table %} + {% elif block.block_type == 'table' %} + {% include_block block %} + {% endif %} +{% endfor %} + +
{% for block in page.trans_body %} diff --git a/publichealth/settings/base.py b/publichealth/settings/base.py index f9d716a..6d4c5df 100644 --- a/publichealth/settings/base.py +++ b/publichealth/settings/base.py @@ -44,6 +44,7 @@ INSTALLED_APPS = [ 'wagtail.contrib.redirects', 'wagtail.contrib.search_promotions', "wagtail.contrib.legacy.richtext", + 'wagtail.contrib.table_block', 'wagtail.embeds', 'wagtail.sites', From 3ff5f1eb50c96c050b76d71a129c4dbc36036098 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 09:32:09 +0200 Subject: [PATCH 02/14] Working TableBlock (but it would be lot easier using a RawHTMLBlock) --- publichealth/home/models/models.py | 35 +++++++++++++++---- .../templates/home/article_index_page.html | 8 +++++ .../home/templates/home/page_content.html | 5 +-- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 725edcd..7f9fd03 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -50,9 +50,32 @@ class ArticleIndexPage(Page): 'intro_en', ) - table_en = TableBlock() - table_fr = TableBlock() - table_de = TableBlock() + + table_en = StreamField( + [ + ('table_en', TableBlock()) + ], + null=True, + blank = True, + ) + table_de = StreamField( + [ + ('table_de', TableBlock()) + ], + null=True, + blank = True, + ) + table_fr = StreamField( + [ + ('table_fr', TableBlock()) + ], + null=True, + blank = True, + ) + + #table_en = TableBlock() + #table_fr = TableBlock() + #table_de = TableBlock() trans_table = TranslatedField( 'table_de', 'table_fr', @@ -83,9 +106,9 @@ class ArticleIndexPage(Page): FieldPanel('intro_fr'), FieldPanel('title_en'), FieldPanel('intro_en'), - #FieldPanel('table_en'), - #FieldPanel('table_fr'), - #FieldPanel('table_de'), + FieldPanel('table_en'), + FieldPanel('table_fr'), + FieldPanel('table_de'), ImageChooserPanel('feed_image'), MultiFieldPanel( [ diff --git a/publichealth/home/templates/home/article_index_page.html b/publichealth/home/templates/home/article_index_page.html index 6cd4cca..644ff26 100644 --- a/publichealth/home/templates/home/article_index_page.html +++ b/publichealth/home/templates/home/article_index_page.html @@ -34,6 +34,14 @@
{% endfor %}
+ +
+{% for block in page.trans_table %} + {% if block.block_type == 'table_en' or block.block_type == 'table_fr' or block.block_type == 'table_de' %} + {% include_block block %} + {% endif %} +{% endfor %} +
diff --git a/publichealth/home/templates/home/page_content.html b/publichealth/home/templates/home/page_content.html index a2cb8a1..57ea93a 100644 --- a/publichealth/home/templates/home/page_content.html +++ b/publichealth/home/templates/home/page_content.html @@ -30,11 +30,12 @@ {% endfor %} - +

Mmmm

{% for block in page.trans_table %} - {% elif block.block_type == 'table' %} + {% if block.block_type == 'table' %} + Inside if {% include_block block %} {% endif %} {% endfor %} From 6fa462dcf698c8d60ae7f092c0820a9c3cf6f2d0 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:09:50 +0530 Subject: [PATCH 03/14] Minimal table style --- .../home/templates/home/article_index_page.html | 2 +- publichealth/static/css/main.scss | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/publichealth/home/templates/home/article_index_page.html b/publichealth/home/templates/home/article_index_page.html index 644ff26..83fa86c 100644 --- a/publichealth/home/templates/home/article_index_page.html +++ b/publichealth/home/templates/home/article_index_page.html @@ -35,7 +35,7 @@ {% endfor %}
-
+
{% for block in page.trans_table %} {% if block.block_type == 'table_en' or block.block_type == 'table_fr' or block.block_type == 'table_de' %} {% include_block block %} diff --git a/publichealth/static/css/main.scss b/publichealth/static/css/main.scss index 006b7f2..7bb9576 100644 --- a/publichealth/static/css/main.scss +++ b/publichealth/static/css/main.scss @@ -128,12 +128,16 @@ $slider-nav: 200px; // Fix Bootstrap 3 warning .media, .media-body { zoom: none !important; transform: scale(1); } - + #mc_embed_signup input[type=radio] { -webkit-appearance: none; padding: 0px;margin-top: 0px; -} +} #mc_embed_signup { - background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; + background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; +} + +.table-program td th { + padding: 0 10px !important; } @import "subsites"; From c70b86a54bb0ac0ace54e026277e8aca2cd68b5e Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:16:57 +0530 Subject: [PATCH 04/14] Revert back change in page_content --- publichealth/home/templates/home/page_content.html | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/publichealth/home/templates/home/page_content.html b/publichealth/home/templates/home/page_content.html index 57ea93a..a2c4165 100644 --- a/publichealth/home/templates/home/page_content.html +++ b/publichealth/home/templates/home/page_content.html @@ -27,19 +27,9 @@

{% include_block block %}

- -{% endfor %} -
-

Mmmm

- -
-{% for block in page.trans_table %} - {% if block.block_type == 'table' %} - Inside if - {% include_block block %} {% endif %} {% endfor %} - +
From a6a00a33f38431de8b8e12a3992c2549ad29e79c Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:21:11 +0530 Subject: [PATCH 05/14] Attempt classname for table --- publichealth/home/templates/home/article_index_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/templates/home/article_index_page.html b/publichealth/home/templates/home/article_index_page.html index 83fa86c..ac25181 100644 --- a/publichealth/home/templates/home/article_index_page.html +++ b/publichealth/home/templates/home/article_index_page.html @@ -38,7 +38,7 @@
{% for block in page.trans_table %} {% if block.block_type == 'table_en' or block.block_type == 'table_fr' or block.block_type == 'table_de' %} - {% include_block block %} + {% include_block block with classname="table-program" %} {% endif %} {% endfor %}
From 0691476d99b1a576e5b3fc16f014befee10462d5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:45:46 +0530 Subject: [PATCH 06/14] Cleanup unused code + format --- publichealth/home/models/models.py | 32 ++++-------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 7f9fd03..7ebbad6 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -50,32 +50,28 @@ class ArticleIndexPage(Page): 'intro_en', ) - table_en = StreamField( [ ('table_en', TableBlock()) ], null=True, - blank = True, + blank=True, ) table_de = StreamField( [ ('table_de', TableBlock()) ], null=True, - blank = True, + blank=True, ) table_fr = StreamField( [ ('table_fr', TableBlock()) ], null=True, - blank = True, + blank=True, ) - #table_en = TableBlock() - #table_fr = TableBlock() - #table_de = TableBlock() trans_table = TranslatedField( 'table_de', 'table_fr', @@ -204,14 +200,6 @@ class ArticlePage(Page): 'body_fr', 'body_en', ) - table_en = TableBlock() - table_fr = TableBlock() - table_de = TableBlock() - trans_table = TranslatedField( - 'table_en', - 'table_fr', - 'table_de', - ) date = models.DateField("Date", null=True, blank=True) @@ -305,15 +293,6 @@ class HomePage(Page): 'body_en', ) - #table_en = TableBlock() - #table_fr = TableBlock() - #table_de = TableBlock() - #trans_table = TranslatedField( - # 'table_en', - # 'table_fr', - # 'table_de', - #) - infos_de = StreamField([ ('info', InfoBlock()) ], null=True, blank=True) @@ -328,27 +307,24 @@ class HomePage(Page): 'infos_fr', 'infos_en', ) -# content_table = StreamField(TableBlock(), verbose_name=_('Content Table'), blank=True) + content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('intro_de', classname="full"), FieldPanel('body_de', classname="full"), StreamFieldPanel('infos_de'), - #StreamFieldPanel('table_de'), ], heading="Deutsch", classname="collapsible collapsed"), MultiFieldPanel([ FieldPanel('intro_fr', classname="full"), FieldPanel('body_fr', classname="full"), StreamFieldPanel('infos_fr'), - #StreamFieldPanel('table_fr'), ], heading="Français", classname="collapsible collapsed"), MultiFieldPanel([ FieldPanel('intro_en', classname="full"), FieldPanel('body_en', classname="full"), StreamFieldPanel('infos_en'), - #StreamFieldPanel('table_fr'), ], heading="English", classname="collapsible collapsed"), ] From f1aa2ad41884ace882cdd9a122d76f7880173d7b Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:51:25 +0530 Subject: [PATCH 07/14] Use custom table template --- publichealth/home/models/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 7ebbad6..341866d 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -52,7 +52,7 @@ class ArticleIndexPage(Page): table_en = StreamField( [ - ('table_en', TableBlock()) + ('table_en', TableBlock(template='templates/home/program_table.html')) ], null=True, blank=True, From 59356a783fe279aaf398efb14805b5d650d3891f Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 16:51:55 +0530 Subject: [PATCH 08/14] Add program_table.html template --- .../home/templates/home/program_table.html | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 publichealth/home/templates/home/program_table.html diff --git a/publichealth/home/templates/home/program_table.html b/publichealth/home/templates/home/program_table.html new file mode 100644 index 0000000..bbbbd89 --- /dev/null +++ b/publichealth/home/templates/home/program_table.html @@ -0,0 +1,48 @@ + + {% if table_header %} + + + {% for column in table_header %} + + {% endfor %} + + + {% endif %} + + {% for row in data %} + + {% for column in row %} + {% if first_col_is_header and forloop.first %} + + {% else %} + + {% endif %} + {% endfor %} + + {% endfor %} + +
+ {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} +
+ {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} + + {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} +
From 78c3548e23f98d3ecf196a91fe718cecc58910df Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 13:36:14 +0200 Subject: [PATCH 09/14] Use correct template path --- publichealth/home/models/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 341866d..8760562 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -52,7 +52,7 @@ class ArticleIndexPage(Page): table_en = StreamField( [ - ('table_en', TableBlock(template='templates/home/program_table.html')) + ('table_en', TableBlock(template='home/program_table.html')) ], null=True, blank=True, From 08ca710b996cc63e1856f498b9e5939451762c41 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 17:16:20 +0530 Subject: [PATCH 10/14] Put styles into template for the moment --- publichealth/home/templates/home/program_table.html | 5 +++++ publichealth/static/css/main.scss | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/publichealth/home/templates/home/program_table.html b/publichealth/home/templates/home/program_table.html index bbbbd89..075d690 100644 --- a/publichealth/home/templates/home/program_table.html +++ b/publichealth/home/templates/home/program_table.html @@ -1,3 +1,8 @@ + {% if table_header %} diff --git a/publichealth/static/css/main.scss b/publichealth/static/css/main.scss index 7bb9576..167e077 100644 --- a/publichealth/static/css/main.scss +++ b/publichealth/static/css/main.scss @@ -136,8 +136,4 @@ $slider-nav: 200px; background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; } -.table-program td th { - padding: 0 10px !important; -} - @import "subsites"; From 86242dbfb1b4f34807b8677527a68fe00238b5ce Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 17:19:11 +0530 Subject: [PATCH 11/14] Add missing comma --- publichealth/home/templates/home/program_table.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/templates/home/program_table.html b/publichealth/home/templates/home/program_table.html index 075d690..24bda39 100644 --- a/publichealth/home/templates/home/program_table.html +++ b/publichealth/home/templates/home/program_table.html @@ -1,5 +1,5 @@ From ae12f220ec97c709befe67edabea3706ffcb78af Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 11 Jul 2022 17:35:12 +0530 Subject: [PATCH 12/14] Use program_table template for all language tables --- publichealth/home/models/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 8760562..2025fda 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -59,14 +59,14 @@ class ArticleIndexPage(Page): ) table_de = StreamField( [ - ('table_de', TableBlock()) + ('table_de', TableBlock(template='home/program_table.html')) ], null=True, blank=True, ) table_fr = StreamField( [ - ('table_fr', TableBlock()) + ('table_fr', TableBlock(template='home/program_table.html')) ], null=True, blank=True, From 673ad6b9242ddcb686bd372fff22320d57be3e94 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 12 Jul 2022 12:11:17 +0530 Subject: [PATCH 13/14] Remove unwanted code --- publichealth/home/templates/home/article_index_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/templates/home/article_index_page.html b/publichealth/home/templates/home/article_index_page.html index 3ed544b..7b878cb 100644 --- a/publichealth/home/templates/home/article_index_page.html +++ b/publichealth/home/templates/home/article_index_page.html @@ -49,7 +49,7 @@
{% for block in page.trans_table %} {% if block.block_type == 'table_en' or block.block_type == 'table_fr' or block.block_type == 'table_de' %} - {% include_block block with classname="table-program" %} + {% include_block block %} {% endif %} {% endfor %}
From ae3a7d5ca9dc95bbbf9b323678e06d6e7835c130 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 12 Jul 2022 12:14:03 +0530 Subject: [PATCH 14/14] Revert back changes to main.scss --- publichealth/static/css/main.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/publichealth/static/css/main.scss b/publichealth/static/css/main.scss index 167e077..006b7f2 100644 --- a/publichealth/static/css/main.scss +++ b/publichealth/static/css/main.scss @@ -128,12 +128,12 @@ $slider-nav: 200px; // Fix Bootstrap 3 warning .media, .media-body { zoom: none !important; transform: scale(1); } - + #mc_embed_signup input[type=radio] { -webkit-appearance: none; padding: 0px;margin-top: 0px; -} +} #mc_embed_signup { - background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; + background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; } @import "subsites";