tickets: Add summary of bookings.
authorMatthijs Kooijman <matthijs@stdin.nl>
Tue, 19 Oct 2010 15:45:59 +0000 (17:45 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Tue, 19 Oct 2010 15:47:30 +0000 (17:47 +0200)
tickets/templates/tickets/bookings.html [new file with mode: 0644]
tickets/views.py
urls.py

diff --git a/tickets/templates/tickets/bookings.html b/tickets/templates/tickets/bookings.html
new file mode 100644 (file)
index 0000000..ae2d6a9
--- /dev/null
@@ -0,0 +1,29 @@
+{% extends "tickets/base.html" %}
+
+{% block content %}
+<h1>Overzicht reserveringen</h1>
+<table>
+    <thead>
+       <tr><th>Voorstelling</th><th>Reserveringen</th><th>Betaald</th></tr>
+    </thead>
+    <tbody>
+{% for show, info in shows.items %}
+<tr><td>{{ show }}</td><td>{{ info.bookings|length }}</td><td>{{ info.payed|length }}</td></tr>
+{% endfor %}
+    </tbody>
+</table>
+
+{% for show, info in shows.items %}
+<h2>{{ show }}</h2>
+<table>
+    <thead>
+       <tr><th>#</th><th>Naam</th><th>Aantal kaarten</th><th>Betaling verwerkt op</th></tr>
+    </thead>
+    <tbody>
+       {% for b in info.bookings %}
+           <tr><td>{{ b.pk }}</td><td>{{ b.name }}</td><td>{{ b.tickets }}</td><td>{{ b.payment }}</td></tr>
+       {% endfor %}
+    </tbody>
+</table>
+{% endfor %}
+{% endblock %}
index a6dff544363d6f6107337f56f3c69de29534ac92..4eca48d94739342c8a0e87e5cc33931aa936152d 100644 (file)
@@ -7,7 +7,7 @@ from django.shortcuts import render_to_response
 from django.template import RequestContext
 from django.contrib.auth.decorators import permission_required
 
-from models import Booking, TICKET_PRICE
+from models import Booking, TICKET_PRICE, SHOW_CHOICES
 
 class BookingForm(django.forms.ModelForm):
     class Meta:
@@ -127,3 +127,15 @@ def payments(request):
         c['amount'] = sum([b.price for b in bookings])
 
     return render_to_response('tickets/payments.html', c, context_instance=RequestContext(request))
+
+@permission_required('tickets.change_booking')
+def bookings(request):
+    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),
+        }
+
+    c = { 'shows' : shows }
+    return render_to_response('tickets/bookings.html', c, context_instance=RequestContext(request))
diff --git a/urls.py b/urls.py
index 0eef5e4f1ecf1372b990d96a1e1a96b6fd0a5f80..4c9da01bd77fb6dd26c9e628252713c2936e1314 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -6,6 +6,7 @@ admin.autodiscover()
 urlpatterns = patterns('',
     (r'^$', 'dorestad-bookings.tickets.views.book'),
     url(r'^betalingen/$', 'dorestad-bookings.tickets.views.payments', name='payments'),
+    url(r'^overzicht/$', 'dorestad-bookings.tickets.views.bookings', name='bookings'),
     # Example:
     # (r'^dorestad1493/', include('dorestad1493.foo.urls')),