Mercurial > public > sg101
diff contact/views.py @ 1070:6ac56115e0a8
Convert contact form & views to V3.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 09 Apr 2016 17:15:32 -0500 |
parents | 38db6ec61af3 |
children | b957e4829a03 |
line wrap: on
line diff
--- a/contact/views.py Tue Apr 05 20:40:09 2016 -0500 +++ b/contact/views.py Sat Apr 09 17:15:32 2016 -0500 @@ -1,6 +1,7 @@ """Views for the contact application.""" from django.shortcuts import redirect, render +from django.views.generic import TemplateView from contact.forms import ContactForm from core.functions import get_full_name @@ -15,7 +16,10 @@ else: initial_data = {} if request.user.is_authenticated(): - name = get_full_name(request.user) + name = get_full_name(request.user).strip() + if name != request.user.username: + name = '{} ({})'.format(name, request.user.username) + initial_data = {'name': name, 'email': request.user.email} subject = request.GET.get('subject') @@ -24,4 +28,16 @@ form = ContactForm(initial=initial_data) - return render(request, 'contact/contact_form.html', {'form': form}) + return render(request, 'contact/contact_form.html', { + 'form': form, + 'V3_DESIGN': True, + }) + + +class ContactThanksView(TemplateView): + template_name = 'contact/contact_thanks.html' + + def get_context_data(self, **kwargs): + context = super(ContactThanksView, self).get_context_data(**kwargs) + context['V3_DESIGN'] = True + return context