Skip to content

Commit 973a015

Browse files
committed
Changed home view to be a FormView and started form processing
1 parent 03dd1a3 commit 973a015

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pythonkc_site/views.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
from django.conf import settings
5+
from django.core.exceptions import ImproperlyConfigured
6+
from django.core.urlresolvers import reverse
7+
from django.views.generic import FormView
58
from django.views.generic.base import TemplateView
69
from pythonkc_meetups import PythonKCMeetups
710
from pythonkc_site.forms import ContactForm
@@ -17,8 +20,17 @@
1720
num_past_events = getattr(settings, 'MEETUP_SHOW_PAST_EVENTS', 3)
1821

1922

20-
class PythonKCHome(TemplateView):
23+
class PythonKCHome(FormView):
2124
template_name = 'index.html'
25+
form_class = ContactForm
26+
27+
def get_success_url(self):
28+
return reverse('home')
29+
30+
def form_valid(self, form):
31+
# TODO send email
32+
# TODO create success msg with msg framework
33+
return super(PythonKCHome, self).form_valid(form)
2234

2335
def get_context_data(self, **kwargs):
2436
# NOTE Instead of individually caching next/past events, we're
@@ -35,7 +47,7 @@ def get_past_events():
3547
return {
3648
'next_event': get_next_event(),
3749
'past_events': get_past_events(),
38-
'form': ContactForm()
50+
'form': kwargs.get('form', None) or ContactForm()
3951
}
4052

4153

0 commit comments

Comments
 (0)