From eaae3c346d237c9fb385d05e57f9d43a841e00f4 Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Mon, 26 Feb 2018 23:15:16 -0500 Subject: [PATCH] Hide regions with no attorneys in them --- charter_members/templates/all.html | 41 ++++++++++--------- charter_members/templatetags/__init__.py | 0 .../templatetags/charter_members_extra.py | 9 ++++ 3 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 charter_members/templatetags/__init__.py create mode 100644 charter_members/templatetags/charter_members_extra.py diff --git a/charter_members/templates/all.html b/charter_members/templates/all.html index 15b0814..3f4ff8f 100644 --- a/charter_members/templates/all.html +++ b/charter_members/templates/all.html @@ -1,30 +1,33 @@ {% extends 'base.html' %} +{% load charter_members_extra %} {% block body %}
{% for region in region %} -
-
-

{{ region }}

-
-
- {% for attorney in attorneys %} - {% if attorney.region == region %} - -
- -
{{ attorney.first_name }} {{ attorney.last_name }}
- {{ attorney.position }} -
-
-
- {% endif %} - {% endfor %} + {% if attorneys|filter_region:region|length > 0 %} +
+
+

{{ region }}

+
+
+ {% for attorney in attorneys %} + {% if attorney.region == region %} + +
+ +
{{ attorney.first_name }} {{ attorney.last_name }}
+ {{ attorney.position }} +
+
+
+ {% endif %} + {% endfor %} +
-
+ {% endif %} {% endfor %} {% if other %}
diff --git a/charter_members/templatetags/__init__.py b/charter_members/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/charter_members/templatetags/charter_members_extra.py b/charter_members/templatetags/charter_members_extra.py new file mode 100644 index 0000000..959e239 --- /dev/null +++ b/charter_members/templatetags/charter_members_extra.py @@ -0,0 +1,9 @@ +from django import template + + +register = template.Library() + + +@register.filter +def filter_region(things, args): + return things.filter(region=args)