gremmie@1: # Create your views here. gremmie@1: gremmie@1: from django.shortcuts import render_to_response gremmie@1: from django.template import RequestContext gremmie@1: from django.http import HttpResponseRedirect gremmie@1: from django.core.urlresolvers import reverse gremmie@1: gremmie@1: from contact.forms import ContactForm gremmie@1: from core.functions import get_full_name gremmie@1: gremmie@1: gremmie@1: def contact_form(request): gremmie@1: if request.method == 'POST': gremmie@1: form = ContactForm(request.POST) gremmie@1: if form.is_valid(): gremmie@1: form.save() gremmie@1: return HttpResponseRedirect(reverse('contact.views.contact_thanks')) gremmie@1: else: gremmie@1: initial_data = {} gremmie@1: if request.user.is_authenticated(): gremmie@1: name = get_full_name(request.user) gremmie@1: initial_data = {'name' : name, 'email' : request.user.email} gremmie@1: gremmie@1: form = ContactForm(initial = initial_data) gremmie@1: gremmie@1: return render_to_response('contact/contact_form.html', gremmie@1: {'form' : form}, gremmie@1: context_instance = RequestContext(request)) gremmie@1: gremmie@1: gremmie@1: def contact_thanks(request): gremmie@1: return render_to_response('contact/contact_thanks.html', gremmie@1: context_instance = RequestContext(request))