1
# Create your views here.
1
from django.views.generic.simple import direct_to_template
2
from swevote.models import VotingLocal, Municipality
3
from management.commands.valbokmanage import distance
4
from django.views.decorators.cache import cache_page
7
def list_locals(request):
9
for l in VotingLocal.objects.order_by('municipality__county', 'municipality', 'name'):
10
if l.districts.count > 1:
13
'address1': d.address1,
14
'address2': d.address2,
15
'address3': d.address3,
16
'distance': int(round(distance(d, l))),
17
'distributor': '*' if d.vsdata.distributor else '-',
18
'first_watch': '*' if d.vsdata.first_watch else '-',
19
'second_watch': '*' if d.vsdata.second_watch else '-',
20
'third_watch': '*' if d.vsdata.third_watch else '-',
21
} for d in l.districts.order_by('name')]
27
'county': l.municipality.county,
28
'municipality': l.municipality,
30
'address1': l.address1,
31
'address2': l.address2,
32
'address3': l.address3,
34
'districts_count': l.districts.count(),
35
'districts': districts,
38
'distributor': '*' if l.localdata.distributor else '-',
39
'first_watch': '*' if l.localdata.first_watch else '-',
40
'second_watch': '*' if l.localdata.second_watch else '-',
41
'third_watch': '*' if l.localdata.third_watch else '-',
44
return direct_to_template(request, "list_votinglocals.html", {
45
'all_locals': all_locals})