Skip to content
Snippets Groups Projects
Commit f9376905 authored by Richard Mathot's avatar Richard Mathot
Browse files

[FIX] survey: avoid navigation crash

If a survey has "allow users to go back" option enabled, users can go back to previous pages and change their answers before submitting the whole survey.

This commit fixes the very special case, when the user reaches the last page of the survey, then click on "Previous" button, then reopen the survey from the invitation URL (/survey/fill/<survey_id>/<token> without the /prev flag in the URL). This won't crash anymore.

This commit fixes #2658 and #2680.
parent b117fcfb
No related branches found
No related tags found
No related merge requests found
......@@ -166,6 +166,11 @@ class WebsiteSurvey(http.Controller):
elif user_input.state == 'skip':
flag = (True if prev and prev == 'prev' else False)
page, page_nr, last = survey_obj.next_page(cr, uid, user_input, user_input.last_displayed_page_id.id, go_back=flag, context=context)
#special case if you click "previous" from the last page, then leave the survey, then reopen it from the URL, avoid crash
if not page:
page, page_nr, last = survey_obj.next_page(cr, uid, user_input, user_input.last_displayed_page_id.id, go_back=True, context=context)
data = {'survey': survey, 'page': page, 'page_nr': page_nr, 'token': user_input.token}
if last:
data.update({'last': True})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment