X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=tickets%2Fviews.py;h=4eca48d94739342c8a0e87e5cc33931aa936152d;hb=97514165a01d41917c6eae9c0d43f6766296712e;hp=a6dff544363d6f6107337f56f3c69de29534ac92;hpb=7d65c823b5324ef7cbef8a27fa0e8c45bb19278f;p=matthijs%2Fprojects%2Fdorestad-bookings.git 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))