diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/contact/views.py	Mon Apr 06 02:43:12 2009 +0000
@@ -0,0 +1,33 @@
+# Create your views here.
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.http import HttpResponseRedirect
+from django.core.urlresolvers import reverse
+
+from contact.forms import ContactForm
+from core.functions import get_full_name
+
+
+def contact_form(request):
+   if request.method == 'POST':
+      form = ContactForm(request.POST)
+      if form.is_valid():
+         form.save()
+         return HttpResponseRedirect(reverse('contact.views.contact_thanks'))
+   else:
+      initial_data = {}
+      if request.user.is_authenticated():
+         name = get_full_name(request.user)
+         initial_data = {'name' : name, 'email' : request.user.email}
+
+      form = ContactForm(initial = initial_data)
+
+   return render_to_response('contact/contact_form.html', 
+         {'form' : form}, 
+         context_instance = RequestContext(request))
+
+
+def contact_thanks(request):
+   return render_to_response('contact/contact_thanks.html', 
+         context_instance = RequestContext(request))