[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.
This commit is contained in:
Richard Mathot 2015-01-16 17:10:20 +01:00
parent b117fcfbac
commit f9376905cc
1 changed files with 5 additions and 0 deletions

View File

@ -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})