Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Commit

Permalink
redirect user to translated page if langauge changed when on survey
Browse files Browse the repository at this point in the history
  • Loading branch information
codiebeulaine committed Jul 11, 2018
1 parent fa96aba commit cdba07d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion molo/surveys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ def serve_questions(self, request):
When the last step is submitted correctly, the whole form is saved in
the DB.
"""
context = self.get_context(request)
# this will only return a page if there is a translation
page = context['page'].get_translation_for(
locale=request.LANGUAGE_CODE, site=request.site)
if page:
# if there is a translation, redirect to the translated page
return redirect(page.url)
survey_data = self.load_data(request)

paginator = SkipLogicPaginator(
Expand Down Expand Up @@ -366,7 +373,7 @@ def serve_questions(self, request):
# Create empty form for non-POST requests
form_class = self.get_form_class_for_step(step)
form = form_class(page=self, user=request.user)
context = self.get_context(request)

context['form'] = form
context['fields_step'] = step
context['is_intermediate_step'] = step.possibly_has_next()
Expand Down

0 comments on commit cdba07d

Please sign in to comment.