From 41bc3c036aebd0e3b7e5b0ffad5dac2c3d265fc2 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 11 Apr 2017 23:38:59 +0200 Subject: [PATCH] Contact info header --- publichealth/home/models/snippets.py | 2 +- .../home/templates/tags/contact_links.html | 7 +++++++ publichealth/home/templates/tags/contact_name.html | 1 + publichealth/home/templatetags/information.py | 14 ++++++++++++++ publichealth/templates/header.html | 14 +++++--------- 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 publichealth/home/templates/tags/contact_links.html create mode 100644 publichealth/home/templates/tags/contact_name.html diff --git a/publichealth/home/models/snippets.py b/publichealth/home/models/snippets.py index 8898e46..4dc397e 100644 --- a/publichealth/home/models/snippets.py +++ b/publichealth/home/models/snippets.py @@ -39,7 +39,7 @@ class Contact(models.Model): def www_domain(self): return self.www.replace('http://', '').replace('https://', '') def trans_title_styled(self): - v = self.trans_title + v = self.trans_title.split(' ') if len(v) != 3: return v return "%s %s %s" % tuple(v) def __str__(self): diff --git a/publichealth/home/templates/tags/contact_links.html b/publichealth/home/templates/tags/contact_links.html new file mode 100644 index 0000000..1fbe73f --- /dev/null +++ b/publichealth/home/templates/tags/contact_links.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/publichealth/home/templates/tags/contact_name.html b/publichealth/home/templates/tags/contact_name.html new file mode 100644 index 0000000..91b73c6 --- /dev/null +++ b/publichealth/home/templates/tags/contact_name.html @@ -0,0 +1 @@ +{{ contact.trans_title_styled|safe }} diff --git a/publichealth/home/templatetags/information.py b/publichealth/home/templatetags/information.py index ddf9351..090ce05 100644 --- a/publichealth/home/templatetags/information.py +++ b/publichealth/home/templatetags/information.py @@ -19,3 +19,17 @@ def contact_form(): return { 'contact': Contact.objects.last(), } + +# Contact links (header) +@register.inclusion_tag('tags/contact_links.html') +def contact_links(): + return { + 'contact': Contact.objects.last(), + } + +# Styled contact name (header) +@register.inclusion_tag('tags/contact_name.html') +def contact_name(): + return { + 'contact': Contact.objects.last(), + } diff --git a/publichealth/templates/header.html b/publichealth/templates/header.html index 306a435..8d5f9c8 100644 --- a/publichealth/templates/header.html +++ b/publichealth/templates/header.html @@ -1,4 +1,4 @@ -{% load wagtailcore_tags navigation %} +{% load wagtailcore_tags navigation information %} {% get_site_root as site_root %}