oacpl/charter_members/views.py

17 lines
542 B
Python
Raw Normal View History

2018-01-14 17:55:35 -05:00
from django.db.models import Count
2017-08-17 13:20:57 -04:00
from django.shortcuts import render
2018-01-25 00:18:13 -05:00
from .models import Region, Attorney
2017-08-17 13:20:57 -04:00
2017-09-03 15:59:37 -04:00
def index(request, id):
attorney = Attorney.objects.get(id=id)
2017-08-17 13:20:57 -04:00
return render(request, 'attorney.html', {'attorney': attorney})
2018-01-14 17:55:35 -05:00
def all(request):
2018-01-25 00:18:13 -05:00
region = Region.objects.all().order_by('name')
attorneys = Attorney.objects.all().annotate(Count('region'))
other = Attorney.objects.filter(region=None).count() > 0
return render(request, 'all.html', {'region': region, 'attorneys': attorneys, 'other': other})