0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-24 10:58:52 +01:00

Revert "Split wagtailforms landing page into separate view"

This reverts commit 21ac2e3ab8.
This commit is contained in:
Karl Hobley 2014-06-27 12:17:57 +01:00
parent 09bf8ceb9c
commit 749df44e06
2 changed files with 12 additions and 26 deletions

View File

@ -1,5 +1,5 @@
from django.db import models
from django.shortcuts import render, redirect
from django.shortcuts import render
from django.utils.translation import ugettext_lazy as _
from django.utils.text import slugify
@ -111,7 +111,6 @@ class AbstractForm(Page):
"""A Form Page. Pages implementing a form should inhert from it"""
form_builder = FormBuilder
landing_page_path = 'done'
is_abstract = True # Don't display me in "Add"
def __init__(self, *args, **kwargs):
@ -153,8 +152,11 @@ class AbstractForm(Page):
form_processor = self.form_processing_backend()
form_processor.process(self, form)
# Redirect to the landing page
return redirect(self.url + self.landing_page_path + '/')
# render the landing_page
# TODO: It is much better to redirect to it
return render(request, self.landing_page_template, {
'self': self,
})
else:
form = form_class(**form_params)
@ -163,18 +165,6 @@ class AbstractForm(Page):
'form': form,
})
def serve_landing(self, request):
return render(request, self.landing_page_template, {
'self': self,
})
def route(self, request, path_components):
# Check if this request is for the landing page
if self.live and path_components == [self.landing_page_path]:
return self.serve_landing(request)
return super(AbstractForm, self).route(request, path_components)
def get_page_modes(self):
return [
('form', 'Form'),
@ -183,7 +173,9 @@ class AbstractForm(Page):
def show_as_mode(self, mode):
if mode == 'landing':
return self.serve_landing(self.dummy_request())
return render(self.dummy_request(), self.landing_page_template, {
'self': self,
})
else:
return super(AbstractForm, self).show_as_mode(mode)

View File

@ -38,7 +38,9 @@ class TestFormSubmission(TestCase):
})
# Check response
self.assertEqual(response.status_code, 302)
self.assertContains(response, "Thank you for your feedback.")
self.assertTemplateNotUsed(response, 'tests/form_page.html')
self.assertTemplateUsed(response, 'tests/form_page_landing.html')
# Check that an email was sent
self.assertEqual(len(mail.outbox), 1)
@ -51,14 +53,6 @@ class TestFormSubmission(TestCase):
form_page = Page.objects.get(url_path='/home/contact-us/')
self.assertTrue(FormSubmission.objects.filter(page=form_page, form_data__contains='hello world').exists())
def test_get_landing_page(self):
response = self.client.get('/contact-us/done/')
# Check response
self.assertContains(response, "Thank you for your feedback.")
self.assertTemplateNotUsed(response, 'tests/form_page.html')
self.assertTemplateUsed(response, 'tests/form_page_landing.html')
class TestPageModes(TestCase):
fixtures = ['test.json']