From 1db8e2910fa6ef8f2770a31db8ed134a3e63d4dc Mon Sep 17 00:00:00 2001
From: Jake Howard
Date: Tue, 5 Apr 2016 22:07:16 +0100
Subject: [PATCH] Add about contact form page
---
project/pages/urls.py | 6 +++---
project/pages/views.py | 11 +++++++++++
templates/about/index.html | 4 ++--
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/project/pages/urls.py b/project/pages/urls.py
index f5d7841..a1def4b 100644
--- a/project/pages/urls.py
+++ b/project/pages/urls.py
@@ -1,8 +1,8 @@
from django.conf.urls import include, url
-from .views import page_view, index_view
+from .views import page_view, index_view, AboutView
urlpatterns = [
- url(r'^(?P.*)/', page_view, name='page'),
- url(r'^$', index_view, name='page'),
+ url(r'^about/?$', AboutView.as_view(), name='about'),
+ url(r'^(?P.*)', page_view, name='page'),
]
diff --git a/project/pages/views.py b/project/pages/views.py
index 3ffe7ce..e62dc02 100644
--- a/project/pages/views.py
+++ b/project/pages/views.py
@@ -29,3 +29,14 @@ def page_view(request, path):
def index_view(request):
return page_view(request, 'index')
+
+
+class AboutView(FormView):
+ template_name = 'about/index.html'
+ success_url = '/about/?sent'
+ form_class = ContactForm
+
+ def get_context_data(self, **kwargs):
+ context = dict(super().get_context_data(**kwargs), **get_context('/about'))
+ context['sent'] = 'sent' not in self.request.GET
+ return context
diff --git a/templates/about/index.html b/templates/about/index.html
index 52929c7..6c31c9c 100644
--- a/templates/about/index.html
+++ b/templates/about/index.html
@@ -21,7 +21,7 @@
Some info about my website, which clearly works well as you're using it right now!
- More Info
+ More Info
@@ -37,7 +37,7 @@
Some info about me. Although not very much. Because Privacy!
- More Info
+ More Info