blob: 0b0b1682792d8035986247b4efb03a143e602e59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from pgweb.util.contexts import render_pgweb
from .models import PUG
def index(request):
"""
contains list of PUGs, in country/locale alphabetical order
"""
pug_list = []
for pug in PUG.objects.filter(approved=True).order_by('country__name', 'locale').all():
if pug_list and pug_list[-1].get('country') == pug.country.name:
pug_list[-1]['pugs'].append(pug)
else:
pug_list.append({
'country': pug.country.name,
'pugs': [pug]
})
return render_pgweb(request, 'community', 'pugs/index.html', {
'pug_list': pug_list,
})
|