model=Booking
exclude=['payment']
-def confirm_booking(booking):
+def confirm_booking(booking, template):
from django.core.mail import EmailMessage
context = {'booking' : booking}
- rendered = django.template.loader.render_to_string('tickets/booked.eml', context)
+ rendered = django.template.loader.render_to_string(template, context)
(headers, body) = rendered.strip().split('\n\n', 1)
# Turn the headers into a dict so EmailMessage can turn them into a
if f.is_valid():
booking = f.save()
- confirm_booking(booking)
+ confirm_booking(booking, 'tickets/booked.eml')
return render_to_response('tickets/booked.html', {'booking' : booking}, context_instance=RequestContext(request))
return render_to_response('tickets/bookingform.html', {'form' : f}, context_instance=RequestContext(request))