@permission_required('tickets.change_booking')
def bookings(request):
- shows = {}
+ shows = []
for (show, show_desc) in SHOW_CHOICES:
- shows[show_desc] = {
- 'bookings' : Booking.objects.filter(show=show),
- 'payed' : Booking.objects.filter(show=show, payment__isnull=False),
- }
+ bookings = Booking.objects.filter(show=show)
+ # shows is a list of (show_desc, infodict) tuples
+ shows.append((show_desc, {
+ 'bookings' : bookings,
+ 'tickets' : sum([b.tickets for b in bookings]),
+ 'payed' : sum([b.tickets for b in bookings if b.payment is not None]),
+ }))
c = { 'shows' : shows }
return render_to_response('tickets/bookings.html', c, context_instance=RequestContext(request))