From e3af7ccc4e55de45e922155669f0d428936ad460 Mon Sep 17 00:00:00 2001 From: Nicolas Joyard <joyard.nicolas@gmail.com> Date: Thu, 2 Jun 2016 08:05:35 +0200 Subject: [PATCH] Add postal addresses --- memopol/templatetags/memopol_tags.py | 6 ++++++ templates/representatives/_address_block.haml | 9 +++++++++ .../representatives/_representative_block.haml | 16 ++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 templates/representatives/_address_block.haml diff --git a/memopol/templatetags/memopol_tags.py b/memopol/templatetags/memopol_tags.py index 00817ab4..2fe32619 100644 --- a/memopol/templatetags/memopol_tags.py +++ b/memopol/templatetags/memopol_tags.py @@ -24,3 +24,9 @@ def website_link(url): short_url = re.sub(r'^https?://([^/]+).*', '\\1', url) return mark_safe(link.format(network='website', url=url, label=short_url)) + + +@register.filter +def email_link(address): + return mark_safe(link.format(network='email', url='mailto:%s' % address, + label=address)) diff --git a/templates/representatives/_address_block.haml b/templates/representatives/_address_block.haml new file mode 100644 index 00000000..232aa0f7 --- /dev/null +++ b/templates/representatives/_address_block.haml @@ -0,0 +1,9 @@ +.address + - if address.floor or address.office_number + .detail + - if address.floor + %span.floor Floor {{ address.floor }} + - if address.office_number + %span.office Office {{ address.office_number }} + .street {{ address.number }} {{ address.street }} + .city {{ address.city }} {{ address.postcode }}, {{ address.country.name }} diff --git a/templates/representatives/_representative_block.haml b/templates/representatives/_representative_block.haml index ca5797bf..4ba44cdb 100644 --- a/templates/representatives/_representative_block.haml +++ b/templates/representatives/_representative_block.haml @@ -57,3 +57,19 @@ %td - for site in representative.other_websites = site.url|website_link + + .row + %h2 Contact information + %table.table.table-condensed.detail-view + - for email in representative.email_set.all + %tr + %th E-mail + %td + = email.email|email_link + + - for address in representative.address_set.all + %tr + %th + = address.name + %td + - include 'representatives/_address_block.html' with address=address -- GitLab