From 97514165a01d41917c6eae9c0d43f6766296712e Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 19 Oct 2010 17:45:59 +0200 Subject: [PATCH] tickets: Add summary of bookings. --- tickets/templates/tickets/bookings.html | 29 +++++++++++++++++++++++++ tickets/views.py | 14 +++++++++++- urls.py | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tickets/templates/tickets/bookings.html diff --git a/tickets/templates/tickets/bookings.html b/tickets/templates/tickets/bookings.html new file mode 100644 index 0000000..ae2d6a9 --- /dev/null +++ b/tickets/templates/tickets/bookings.html @@ -0,0 +1,29 @@ +{% extends "tickets/base.html" %} + +{% block content %} +

Overzicht reserveringen

+ + + + + +{% for show, info in shows.items %} + +{% endfor %} + +
VoorstellingReserveringenBetaald
{{ show }}{{ info.bookings|length }}{{ info.payed|length }}
+ +{% for show, info in shows.items %} +

{{ show }}

+ + + + + + {% for b in info.bookings %} + + {% endfor %} + +
#NaamAantal kaartenBetaling verwerkt op
{{ b.pk }}{{ b.name }}{{ b.tickets }}{{ b.payment }}
+{% endfor %} +{% endblock %} diff --git a/tickets/views.py b/tickets/views.py index a6dff54..4eca48d 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -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 0eef5e4..4c9da01 100644 --- 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')), -- 2.30.2