From 048faf479c6bcf4e3f22f98d3fb894c8df839a94 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 7 Feb 2022 12:19:14 +0530 Subject: [PATCH] Add functionality to show news_letter --- publichealth/home/models/snippets.py | 16 ++++++++++++++++ .../home/templates/tags/news_letter.html | 3 +++ publichealth/home/templatetags/information.py | 8 ++++++++ publichealth/templates/footer.html | 1 + 4 files changed, 28 insertions(+) create mode 100644 publichealth/home/templates/tags/news_letter.html diff --git a/publichealth/home/models/snippets.py b/publichealth/home/models/snippets.py index a18f9ca..5d058fe 100644 --- a/publichealth/home/models/snippets.py +++ b/publichealth/home/models/snippets.py @@ -97,6 +97,15 @@ class Contact(models.Model): on_delete=models.SET_NULL, related_name='+', ) + news_letter_url = models.URLField(default='', blank=True) + news_letter_text = models.CharField(default='', blank=True, max_length=256) + news_letter_text_fr = models.CharField(max_length=255, blank=True, default="") + news_letter_text_en = models.CharField(max_length=255, blank=True, default="") + trans_news_letter_text = TranslatedField( + 'news_letter_text', + 'news_letter_text_fr', + 'news_letter_text_en', + ) panels = Page.content_panels + [ FieldPanel('title_fr'), @@ -114,6 +123,13 @@ class Contact(models.Model): PageChooserPanel('contact_form', 'home.ContactForm'), ] + panels = panels + [ + FieldPanel('news_letter_url', classname="full"), + FieldPanel('news_letter_text'), + FieldPanel('news_letter_text_fr'), + FieldPanel('news_letter_text_en'), + ] + def phone_link(self): return 'tel:%s' % self.phone.replace(' ', '') def email_link(self): diff --git a/publichealth/home/templates/tags/news_letter.html b/publichealth/home/templates/tags/news_letter.html new file mode 100644 index 0000000..3c2d914 --- /dev/null +++ b/publichealth/home/templates/tags/news_letter.html @@ -0,0 +1,3 @@ +{% if contact.trans_news_letter_text %} +{{ contact.trans_news_letter_text }} +{% endif %} diff --git a/publichealth/home/templatetags/information.py b/publichealth/home/templatetags/information.py index 133a7ea..bc037de 100644 --- a/publichealth/home/templatetags/information.py +++ b/publichealth/home/templatetags/information.py @@ -35,11 +35,19 @@ def get_contacts(the_site): 'socials': social_contacts } + # Contact information (footer) @register.inclusion_tag('tags/contact_info.html') def contact_info(the_site): return get_contacts(the_site) + +# Newsletter (footer) +@register.inclusion_tag('tags/news_letter.html') +def news_letter(the_site): + return get_contacts(the_site) + + # Contact form (footer) @register.inclusion_tag('tags/footer_form.html') def footer_form(the_site): diff --git a/publichealth/templates/footer.html b/publichealth/templates/footer.html index 0245064..0224355 100644 --- a/publichealth/templates/footer.html +++ b/publichealth/templates/footer.html @@ -24,6 +24,7 @@
{% footer_form the_site=the_site %} + {% news_letter the_site=the_site %}