Mercurial > public > sg101
comparison gpp/contact/views.py @ 1:dbd703f7d63a
Initial import of sg101 stuff from private repository.
author | gremmie |
---|---|
date | Mon, 06 Apr 2009 02:43:12 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:900ba3c7b765 | 1:dbd703f7d63a |
---|---|
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)) |