tickets: Don't use a dict of shows in the overview.
authorMatthijs Kooijman <matthijs@stdin.nl>
Mon, 25 Oct 2010 09:24:52 +0000 (11:24 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Mon, 25 Oct 2010 09:24:52 +0000 (11:24 +0200)
Instead, we now use a list of tuples. This ensures that the output
remains properly sorted.

tickets/templates/tickets/bookings.html
tickets/views.py

index 26d0018ffd7e540056684fcffa960ad12e93ae76..0c0348d93e52ac87d786716bde40cc5375b21319 100644 (file)
@@ -7,13 +7,13 @@
        <tr><th>Voorstelling</th><th>Reserveringen</th><th>Gereserveerde kaarten</th><th>Betaalde kaarten</th></tr>
     </thead>
     <tbody>
-{% for show, info in shows.items %}
+{% for show, info in shows %}
 <tr><td>{{ show }}</td><td>{{ info.bookings|length }}</td><td>{{ info.tickets }}</td><td>{{ info.payed|length }}</td></tr>
 {% endfor %}
     </tbody>
 </table>
 
-{% for show, info in shows.items %}
+{% for show, info in shows %}
 <h2>{{ show }}</h2>
 <table>
     <thead>
index db988fe448a280ea34d99839741b3c3ff509b133..5b7ab75e541abfad5009e2b170e57c0f7400e4bd 100644 (file)
@@ -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))