comparison contact/views.py @ 581:ee87ea74d46b

For Django 1.4, rearranged project structure for new manage.py.
author Brian Neal <bgneal@gmail.com>
date Sat, 05 May 2012 17:10:48 -0500
parents gpp/contact/views.py@dbd703f7d63a
children 38db6ec61af3
comparison
equal deleted inserted replaced
580:c525f3e0b5d0 581:ee87ea74d46b
1 # Create your views here.
2
3 from django.shortcuts import render_to_response
4 from django.template import RequestContext
5 from django.http import HttpResponseRedirect
6 from django.core.urlresolvers import reverse
7
8 from contact.forms import ContactForm
9 from core.functions import get_full_name
10
11
12 def contact_form(request):
13 if request.method == 'POST':
14 form = ContactForm(request.POST)
15 if form.is_valid():
16 form.save()
17 return HttpResponseRedirect(reverse('contact.views.contact_thanks'))
18 else:
19 initial_data = {}
20 if request.user.is_authenticated():
21 name = get_full_name(request.user)
22 initial_data = {'name' : name, 'email' : request.user.email}
23
24 form = ContactForm(initial = initial_data)
25
26 return render_to_response('contact/contact_form.html',
27 {'form' : form},
28 context_instance = RequestContext(request))
29
30
31 def contact_thanks(request):
32 return render_to_response('contact/contact_thanks.html',
33 context_instance = RequestContext(request))