Show members not in a region on the all page

This commit is contained in:
Zakary Timson 2018-01-25 00:52:57 -05:00
parent b3a7586779
commit a6f22b2a03
2 changed files with 23 additions and 1 deletions

View File

@ -26,6 +26,27 @@
</div>
</div>
{% endfor %}
{% if other %}
<div class="row bg-white mb-5">
<div class="col-12 pt-3">
<div class="row">
{% for attorney in attorneys %}
{% if not attorney.region %}
<a class="col-3 text-center pt-5" href="{% url 'attorney' attorney.id %}">
<div>
<img class="pb-3" src="/media/{{ attorney.image }}"
style="width: auto; max-width: 100%; height: 200px"/>
<h5 class="text-dark-primary">{{ attorney.first_name }} {{ attorney.last_name }}</h5>
<span class="text-light-primary">{{ attorney.position }}</span>
<hr>
</div>
</a>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -12,4 +12,5 @@ def index(request, id):
def all(request):
region = Region.objects.all().order_by('name')
attorneys = Attorney.objects.all().annotate(Count('region'))
return render(request, 'all.html', {'region': region, 'attorneys': attorneys})
other = Attorney.objects.filter(region=None).count() > 0
return render(request, 'all.html', {'region': region, 'attorneys': attorneys, 'other': other})