From 8e3cb97473e051c840069cbeb399153b4c62834c Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 25 Oct 2010 11:24:52 +0200 Subject: [PATCH] tickets: Don't use a dict of shows in the overview. Instead, we now use a list of tuples. This ensures that the output remains properly sorted. --- tickets/templates/tickets/bookings.html | 4 ++-- tickets/views.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tickets/templates/tickets/bookings.html b/tickets/templates/tickets/bookings.html index 26d0018..0c0348d 100644 --- a/tickets/templates/tickets/bookings.html +++ b/tickets/templates/tickets/bookings.html @@ -7,13 +7,13 @@ VoorstellingReserveringenGereserveerde kaartenBetaalde kaarten -{% for show, info in shows.items %} +{% for show, info in shows %} {{ show }}{{ info.bookings|length }}{{ info.tickets }}{{ info.payed|length }} {% endfor %} -{% for show, info in shows.items %} +{% for show, info in shows %}

{{ show }}

diff --git a/tickets/views.py b/tickets/views.py index db988fe..5b7ab75 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -130,14 +130,15 @@ def payments(request): @permission_required('tickets.change_booking') def bookings(request): - shows = {} + shows = [] for (show, show_desc) in SHOW_CHOICES: bookings = Booking.objects.filter(show=show) - shows[show_desc] = { + # shows is a list of (show_desc, infodict) tuples + shows.append((show_desc, { 'bookings' : bookings, 'tickets' : sum([b.tickets for b in bookings]), 'payed' : Booking.objects.filter(show=show, payment__isnull=False), - } + })) c = { 'shows' : shows } return render_to_response('tickets/bookings.html', c, context_instance=RequestContext(request)) -- 2.30.2