From fa76b10f73ec76f504acaa9c3bc3c9d056ed7bae Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Sep 2021 17:55:45 +0530 Subject: [PATCH 1/4] Show member submenu conditionally on de/fr pages --- publichealth/home/templatetags/navigation.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/publichealth/home/templatetags/navigation.py b/publichealth/home/templatetags/navigation.py index b9b66ba..316e5b5 100644 --- a/publichealth/home/templatetags/navigation.py +++ b/publichealth/home/templatetags/navigation.py @@ -67,13 +67,26 @@ def top_menu(context, parent, calling_page=None): } def menuitems_children(parent): + remove_mitglied = False + remove_devenez = False + if 'Qui sommes-nous' in parent.title: + remove_mitglied = True + if 'Über uns' in parent.title: + remove_devenez = True menuitems_children = parent.get_children().live().in_menu().specific() + out_menuitems_children = [] for menuitem in menuitems_children: try: menuitem.title = menuitem.trans_title + if 'devenez' in menuitem.title.lower() and remove_devenez: + continue + elif 'mitglied werden' in menuitem.title.lower() and remove_mitglied: + continue + else: + out_menuitems_children.append(menuitem) except AttributeError: pass - return menuitems_children + return out_menuitems_children # Retrieves the children of the top menu items for the drop downs @register.inclusion_tag('tags/top_menu_children.html', takes_context=True) From df0a219f62652d244a4f31e2d851808c7fe821a3 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Sep 2021 20:24:00 +0530 Subject: [PATCH 2/4] Show devenez membre contact form submenu --- publichealth/home/templatetags/navigation.py | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/publichealth/home/templatetags/navigation.py b/publichealth/home/templatetags/navigation.py index 316e5b5..8dd8f5a 100644 --- a/publichealth/home/templatetags/navigation.py +++ b/publichealth/home/templatetags/navigation.py @@ -2,8 +2,8 @@ from django import template from django.utils import translation -from wagtail.core.models import Site - +from wagtail.core.models import Site, Page +from ..models.forms import ContactForm register = template.Library() @register.simple_tag() @@ -74,19 +74,22 @@ def menuitems_children(parent): if 'Über uns' in parent.title: remove_devenez = True menuitems_children = parent.get_children().live().in_menu().specific() - out_menuitems_children = [] + items_to_remove = [] for menuitem in menuitems_children: try: - menuitem.title = menuitem.trans_title - if 'devenez' in menuitem.title.lower() and remove_devenez: - continue - elif 'mitglied werden' in menuitem.title.lower() and remove_mitglied: - continue + if type(menuitem) == ContactForm: + menuitem.title = menuitem.title.title() else: - out_menuitems_children.append(menuitem) + menuitem.title = menuitem.trans_title + if 'devenez' in menuitem.title.lower() and remove_devenez: + items_to_remove.append(menuitem) + elif 'mitglied werden' in menuitem.title.lower() and remove_mitglied: + items_to_remove.append(menuitem) except AttributeError: pass - return out_menuitems_children + for item in items_to_remove: + menuitems_children = menuitems_children & Page.objects.not_page(item) + return menuitems_children # Retrieves the children of the top menu items for the drop downs @register.inclusion_tag('tags/top_menu_children.html', takes_context=True) From 65b1241054b0d8d4c540a7ee4313f2d567f74d0b Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Sep 2021 20:34:26 +0530 Subject: [PATCH 3/4] Ensure title case for child page title in menu --- publichealth/home/templates/tags/top_menu_children.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publichealth/home/templates/tags/top_menu_children.html b/publichealth/home/templates/tags/top_menu_children.html index ba5f63f..59ba231 100644 --- a/publichealth/home/templates/tags/top_menu_children.html +++ b/publichealth/home/templates/tags/top_menu_children.html @@ -3,6 +3,6 @@ From 0e3b52abc551d19bb336e00a9e6e96d0cfe2cd0e Mon Sep 17 00:00:00 2001 From: Amal Elshihaby Date: Wed, 29 Sep 2021 10:40:34 +0200 Subject: [PATCH 4/4] Task #9790 Add newsletter signup button --- .gitignore | 1 + .../migrations/0030_auto_20210928_1850.py | 29 +++++++++++ .../0031_articleindexpage_subscribe_action.py | 18 +++++++ .../migrations/0032_auto_20210928_1858.py | 33 +++++++++++++ publichealth/home/models/models.py | 21 ++++++++ .../templates/home/article_index_page.html | 5 +- .../templates/home/subscription_form.html | 49 +++++++++++++++++++ publichealth/static/css/main.scss | 7 +++ publichealth/templates/base.html | 26 +++++++++- 9 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 publichealth/home/migrations/0030_auto_20210928_1850.py create mode 100644 publichealth/home/migrations/0031_articleindexpage_subscribe_action.py create mode 100644 publichealth/home/migrations/0032_auto_20210928_1858.py create mode 100644 publichealth/home/templates/home/subscription_form.html diff --git a/.gitignore b/.gitignore index 01020ea..09a87d8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ /node_modules/ /publichealth/static/libs publichealth.home.json +.history diff --git a/publichealth/home/migrations/0030_auto_20210928_1850.py b/publichealth/home/migrations/0030_auto_20210928_1850.py new file mode 100644 index 0000000..45f7cf6 --- /dev/null +++ b/publichealth/home/migrations/0030_auto_20210928_1850.py @@ -0,0 +1,29 @@ +# Generated by Django 3.0.14 on 2021-09-28 16:50 + +from django.db import migrations +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0029_contactformfield_clean_name'), + ] + + operations = [ + migrations.AddField( + model_name='articleindexpage', + name='subscribe_label_de', + field=wagtail.core.fields.RichTextField(blank=True, default=''), + ), + migrations.AddField( + model_name='articleindexpage', + name='subscribe_label_en', + field=wagtail.core.fields.RichTextField(blank=True, default=''), + ), + migrations.AddField( + model_name='articleindexpage', + name='subscribe_label_fr', + field=wagtail.core.fields.RichTextField(blank=True, default=''), + ), + ] diff --git a/publichealth/home/migrations/0031_articleindexpage_subscribe_action.py b/publichealth/home/migrations/0031_articleindexpage_subscribe_action.py new file mode 100644 index 0000000..6188351 --- /dev/null +++ b/publichealth/home/migrations/0031_articleindexpage_subscribe_action.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.14 on 2021-09-28 16:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0030_auto_20210928_1850'), + ] + + operations = [ + migrations.AddField( + model_name='articleindexpage', + name='subscribe_action', + field=models.URLField(blank=True, default=''), + ), + ] diff --git a/publichealth/home/migrations/0032_auto_20210928_1858.py b/publichealth/home/migrations/0032_auto_20210928_1858.py new file mode 100644 index 0000000..3db35e9 --- /dev/null +++ b/publichealth/home/migrations/0032_auto_20210928_1858.py @@ -0,0 +1,33 @@ +# Generated by Django 3.0.14 on 2021-09-28 16:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0031_articleindexpage_subscribe_action'), + ] + + operations = [ + migrations.AlterField( + model_name='articleindexpage', + name='subscribe_action', + field=models.URLField(blank=True, default='', verbose_name='Action'), + ), + migrations.AlterField( + model_name='articleindexpage', + name='subscribe_label_de', + field=models.CharField(blank=True, default='', max_length=250, verbose_name='Button Label (de)'), + ), + migrations.AlterField( + model_name='articleindexpage', + name='subscribe_label_en', + field=models.CharField(blank=True, default='', max_length=250, verbose_name='Button Label (en)'), + ), + migrations.AlterField( + model_name='articleindexpage', + name='subscribe_label_fr', + field=models.CharField(blank=True, default='', max_length=250, verbose_name='Button Label (fr)'), + ), + ] diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index e9f2312..7853dd2 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -47,6 +47,17 @@ class ArticleIndexPage(Page): 'intro_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) + subscribe_action = models.URLField("Action", default='', blank=True) + + trans_subscribe_label = TranslatedField( + 'subscribe_label_de', + 'subscribe_label_fr', + 'subscribe_label_en', + ) + feed_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, @@ -61,6 +72,16 @@ class ArticleIndexPage(Page): FieldPanel('title_en'), FieldPanel('intro_en'), ImageChooserPanel('feed_image'), + MultiFieldPanel( + [ + FieldPanel('subscribe_label_de'), + FieldPanel('subscribe_label_fr'), + FieldPanel('subscribe_label_en'), + FieldPanel('subscribe_action') + ], + heading="Newsletters", + classname="collapsible collapsed" + ) ] def get_context(self, request): diff --git a/publichealth/home/templates/home/article_index_page.html b/publichealth/home/templates/home/article_index_page.html index c4bca27..6cd4cca 100644 --- a/publichealth/home/templates/home/article_index_page.html +++ b/publichealth/home/templates/home/article_index_page.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load wagtailcore_tags wagtailimages_tags %} +{% load i18n wagtailcore_tags wagtailimages_tags %} {% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %} @@ -21,6 +21,9 @@

{{ page.trans_title }}

{{ page.trans_intro|richtext }}

+ {% if page.subscribe_action %} + {% include 'home/subscription_form.html' %} + {% endif %}
{% for entry in articles %}
diff --git a/publichealth/home/templates/home/subscription_form.html b/publichealth/home/templates/home/subscription_form.html new file mode 100644 index 0000000..ce2c91b --- /dev/null +++ b/publichealth/home/templates/home/subscription_form.html @@ -0,0 +1,49 @@ +{{ page.trans_subscribe_label }} + \ No newline at end of file diff --git a/publichealth/static/css/main.scss b/publichealth/static/css/main.scss index e952926..006b7f2 100644 --- a/publichealth/static/css/main.scss +++ b/publichealth/static/css/main.scss @@ -128,5 +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; +} @import "subsites"; diff --git a/publichealth/templates/base.html b/publichealth/templates/base.html index f867fba..bf34b34 100644 --- a/publichealth/templates/base.html +++ b/publichealth/templates/base.html @@ -11,6 +11,9 @@ {% block extra_css %}{% endblock %} + {% if page.subscribe_action %} + + {% endif %} {% compress css %} {% endcompress %} @@ -35,7 +38,28 @@ - + {% if page.subscribe_action %} + + + {% endif %} {% block extra_js %}{% endblock %} {% compress js %}