Skip to content

Commit

Permalink
Added getters for templates in AbstractForm
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagaro authored and gasman committed Oct 13, 2016
1 parent 0cf3b13 commit 9710c29
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
1.8 (xx.xx.xxxx) - IN DEVELOPMENT
~~~~~~~~~~~~~~~~

* Added support of a custom `edit_handler` in site settings (Axel Haustant)
* Added support of a custom `edit_handler` in site settings (Axel Haustant)
* Added `get_landing_page_template` getter method to `AbstractForm` (Gagaro)
* Fix: `AbstractForm` now respects custom `get_template` methods on the page model (Gagaro)


1.7 (xx.xx.xxxx) - IN DEVELOPMENT
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/contrib/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ You now need to create two templates named ``form_page.html`` and ``form_page_la
</body>
</html>

``form_page_landing.html`` is a regular Wagtail template, displayed after the user makes a successful form submission.
``form_page_landing.html`` is a regular Wagtail template, displayed after the user makes a successful form submission. If you want to dynamically override the landing page template, you can do so with the ``get_landing_page_template`` method (in the same way that you would with ``get_template``).


.. _wagtailforms_formsubmissionpanel:
Expand Down
3 changes: 3 additions & 0 deletions docs/releases/1.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ Minor features
~~~~~~~~~~~~~~

* Added support of a custom ``edit_handler`` for site settings. See :ref:`docs for the site settings module <edit_handlers_settings>`. (Axel Haustant)
* Added ``get_landing_page_template`` getter method to ``AbstractForm`` (Gagaro)


Bug fixes
~~~~~~~~~

* ``AbstractForm`` now respects custom ``get_template`` methods on the page model (Gagaro)


Upgrade considerations
======================
Expand Down
9 changes: 6 additions & 3 deletions wagtail/wagtailforms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def get_form(self, *args, **kwargs):

return form_class(*args, **form_params)

def get_landing_page_template(self, request, *args, **kwargs):
return self.landing_page_template

def get_submission_class(self):
"""
Returns submission class.
Expand Down Expand Up @@ -242,7 +245,7 @@ def serve(self, request, *args, **kwargs):
# TODO: It is much better to redirect to it
return render(
request,
self.landing_page_template,
self.get_landing_page_template(request),
self.get_context(request)
)
else:
Expand All @@ -252,7 +255,7 @@ def serve(self, request, *args, **kwargs):
context['form'] = form
return render(
request,
self.template,
self.get_template(request),
context
)

Expand All @@ -265,7 +268,7 @@ def serve_preview(self, request, mode):
if mode == 'landing':
return render(
request,
self.landing_page_template,
self.get_landing_page_template(request),
self.get_context(request)
)
else:
Expand Down

0 comments on commit 9710c29

Please sign in to comment.