Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
apps/cms/contacts: redirect to the right page after submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Magdalena Noffke committed Jul 24, 2019
1 parent 59dbfa9 commit 0837a84
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/cms/contacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ def process_form_submission(self, form):
self.send_mail(form)
return submission

def render_landing_page(
self, request, form_submission=None, *args, **kwargs):
if 'HTTP_REFERER' in request.META \
and request.META.get('HTTP_REFERER'):
messages.add_message(request, messages.SUCCESS,
self.thank_you_text)
return redirect(request.META['HTTP_REFERER'])
return super().render_landing_page(
request, form_submission, *args, **kwargs)

def get_form_fields(self):
fields = list(super().get_form_fields())
fields.insert(0, FormField(
Expand Down

0 comments on commit 0837a84

Please sign in to comment.