From 0e3b52abc551d19bb336e00a9e6e96d0cfe2cd0e Mon Sep 17 00:00:00 2001 From: Amal Elshihaby Date: Wed, 29 Sep 2021 10:40:34 +0200 Subject: [PATCH] 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 %}