From: Matthijs Kooijman Date: Mon, 18 Oct 2010 11:36:19 +0000 (+0200) Subject: tickets: Add basic booking form, view and templates. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=6f122bebb61452b705b1d943f896bc77d6168c63;p=matthijs%2Fprojects%2Fdorestad-bookings.git tickets: Add basic booking form, view and templates. --- diff --git a/tickets/templates/tickets/booked.html b/tickets/templates/tickets/booked.html new file mode 100644 index 0000000..0338b8d --- /dev/null +++ b/tickets/templates/tickets/booked.html @@ -0,0 +1,13 @@ +{% extends "tickets/base.html" %} + +{% block content %} +

Gereserveerd

+

+Je hebt {{ booking.tickets }} kaarten gereserveerd voor de voorstelling op +{{ booking.get_show_display }}, op naam van {{ booking.name }}. Je hebt +hiervoor ook een bevestiging via email ontvangen (op {{ booking.email }}). +

+

+Veel plezier bij de voorstelling! +

+{% endblock %} diff --git a/tickets/templates/tickets/bookingform.html b/tickets/templates/tickets/bookingform.html new file mode 100644 index 0000000..47a740d --- /dev/null +++ b/tickets/templates/tickets/bookingform.html @@ -0,0 +1,16 @@ +{% extends "tickets/base.html" %} + +{% block content %} +

Reserveren

+
+ +{{ form.as_table }} +
+ +
+ +

Het e-mailadres wat je hier invult zal alleen worden gebruikt om je een +bevestiging van je reservering te sturen en om bij eventuele bijzonderheden +met betrekking tot de voorstelling contact op te nemen. +

+{% endblock %} diff --git a/tickets/views.py b/tickets/views.py index 60f00ef..63cf286 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -1 +1,22 @@ # Create your views here. + +import django +from django.shortcuts import render_to_response + +from models import Booking + +class BookingForm(django.forms.ModelForm): + class Meta: + model=Booking + +def book(request): + if request.method == "POST": + f = BookingForm(request.POST) + else: + f = BookingForm() + + if f.is_valid(): + booking = f.save() + return render_to_response('tickets/booked.html', {'booking' : booking}) + + return render_to_response('tickets/bookingform.html', {'form' : f})