comparison mysite/band/views.py @ 5:e602b5302b94

Added support for countries beside the USA.
author Brian Neal <bgneal@gmail.com>
date Thu, 14 May 2009 00:31:39 +0000
parents 0dcfcdf50c62
children dac690ab98b2
comparison
equal deleted inserted replaced
4:432f7467543a 5:e602b5302b94
75 75
76 stats = {} 76 stats = {}
77 venues = set([]) 77 venues = set([])
78 cities = set([]) 78 cities = set([])
79 states = set([]) 79 states = set([])
80 countries = set([])
80 bands = set([]) 81 bands = set([])
81 for gig in previous: 82 for gig in previous:
82 if gig.venue.id not in venues: 83 if gig.venue.id not in venues:
83 venues.add(gig.venue.id) 84 venues.add(gig.venue.id)
84 if gig.venue.city.id not in cities: 85 if gig.venue.city.id not in cities:
85 cities.add(gig.venue.city.id) 86 cities.add(gig.venue.city.id)
86 if gig.venue.city.state and gig.venue.city.state.id not in states: 87 if gig.venue.city.state and gig.venue.city.state.id not in states:
87 states.add(gig.venue.city.state.id) 88 states.add(gig.venue.city.state.id)
89 if gig.venue.city.country and gig.venue.city.country.id not in countries:
90 countries.add(gig.venue.city.country.id)
88 for band in gig.bands.all(): 91 for band in gig.bands.all():
89 if band.id not in bands: 92 if band.id not in bands:
90 bands.add(band.id) 93 bands.add(band.id)
91 94
92 stats['count'] = previous.count() 95 stats['count'] = previous.count()
93 stats['venues'] = len(venues) 96 stats['venues'] = len(venues)
94 stats['cities'] = len(cities) 97 stats['cities'] = len(cities)
95 stats['states'] = len(states) 98 stats['states'] = len(states)
99 stats['countries'] = len(countries)
96 stats['bands'] = len(bands) 100 stats['bands'] = len(bands)
97 101
98 flyerGigs = Gig.objects.exclude(flyer__isnull = True).order_by('-date') 102 flyerGigs = Gig.objects.exclude(flyer__isnull = True).order_by('-date')
99 103
100 return render_to_response('band/gigs.html', 104 return render_to_response('band/gigs.html',