From 6f122bebb61452b705b1d943f896bc77d6168c63 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 18 Oct 2010 13:36:19 +0200 Subject: [PATCH] tickets: Add basic booking form, view and templates. --- tickets/templates/tickets/booked.html | 13 +++++++++++++ tickets/templates/tickets/bookingform.html | 16 ++++++++++++++++ tickets/views.py | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 tickets/templates/tickets/booked.html create mode 100644 tickets/templates/tickets/bookingform.html 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}) -- 2.30.2