Mercurial > public > sg101
annotate contact/views.py @ 813:eca0c17ff9c8
Private message refactor: reports should email admins.
Added tests for reporting messages and ensuring emails are sent
when messages are sent (when user options allow it).
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 08 Sep 2014 20:50:37 -0500 |
parents | ee87ea74d46b |
children | 38db6ec61af3 |
rev | line source |
---|---|
gremmie@1 | 1 # Create your views here. |
gremmie@1 | 2 |
gremmie@1 | 3 from django.shortcuts import render_to_response |
gremmie@1 | 4 from django.template import RequestContext |
gremmie@1 | 5 from django.http import HttpResponseRedirect |
gremmie@1 | 6 from django.core.urlresolvers import reverse |
gremmie@1 | 7 |
gremmie@1 | 8 from contact.forms import ContactForm |
gremmie@1 | 9 from core.functions import get_full_name |
gremmie@1 | 10 |
gremmie@1 | 11 |
gremmie@1 | 12 def contact_form(request): |
gremmie@1 | 13 if request.method == 'POST': |
gremmie@1 | 14 form = ContactForm(request.POST) |
gremmie@1 | 15 if form.is_valid(): |
gremmie@1 | 16 form.save() |
gremmie@1 | 17 return HttpResponseRedirect(reverse('contact.views.contact_thanks')) |
gremmie@1 | 18 else: |
gremmie@1 | 19 initial_data = {} |
gremmie@1 | 20 if request.user.is_authenticated(): |
gremmie@1 | 21 name = get_full_name(request.user) |
gremmie@1 | 22 initial_data = {'name' : name, 'email' : request.user.email} |
gremmie@1 | 23 |
gremmie@1 | 24 form = ContactForm(initial = initial_data) |
gremmie@1 | 25 |
gremmie@1 | 26 return render_to_response('contact/contact_form.html', |
gremmie@1 | 27 {'form' : form}, |
gremmie@1 | 28 context_instance = RequestContext(request)) |
gremmie@1 | 29 |
gremmie@1 | 30 |
gremmie@1 | 31 def contact_thanks(request): |
gremmie@1 | 32 return render_to_response('contact/contact_thanks.html', |
gremmie@1 | 33 context_instance = RequestContext(request)) |