From 2bb1f3315515ee2b7cf634f7dfaaf6648748d33a Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Tue, 23 Mar 2021 10:38:07 +0000 Subject: [PATCH] [IMP] survey: display no question message for live session PURPOSE Before this commit, the survey host had no indication that his survey has no questions. After this commit, he will be displayed with that indication. Before this commit, someone who took the survey had a message implying him to modify the survey to add questions. After this commit the message will say 'No question yet, come back later'. LINKS Task ID : 2456372 PR : odoo/odoo#68231 Signed-off-by: Thibault Delavallee (tde) --- addons/survey/controllers/survey_session_manage.py | 7 +++++++ addons/survey/views/survey_templates_management.xml | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/survey/controllers/survey_session_manage.py b/addons/survey/controllers/survey_session_manage.py index ed84444f5b5..c0935e7a7d7 100644 --- a/addons/survey/controllers/survey_session_manage.py +++ b/addons/survey/controllers/survey_session_manage.py @@ -46,6 +46,8 @@ class UserInputSession(http.Controller): - If the state of the session is 'ready' We render a template allowing the host to showcase the different options of the session and to actually start the session. + If there are no questions, a "void content" is displayed instead to avoid displaying a + blank survey. - If the state of the session is 'in_progress' We render a template allowing the host to show the question results, display the attendees leaderboard or go to the next question of the session. """ @@ -57,6 +59,11 @@ class UserInputSession(http.Controller): return NotFound() if survey.session_state == 'ready': + if not survey.question_ids: + return request.render('survey.survey_void_content', { + 'survey': survey, + 'answer': request.env['survey.user_input'], + }) return request.render('survey.user_input_session_open', { 'survey': survey }) diff --git a/addons/survey/views/survey_templates_management.xml b/addons/survey/views/survey_templates_management.xml index 43007393713..f5aff7caff1 100644 --- a/addons/survey/views/survey_templates_management.xml +++ b/addons/survey/views/survey_templates_management.xml @@ -27,12 +27,16 @@
-

survey is void

-

Please make sure you have at least one question in your survey. You also need at least one section if you chose the "Page per section" layout.
+

survey is empty

+

+ Please make sure you have at least one question in your survey. You also need at least one section if you chose the "Page per section" layout.
Edit in backend

+

+ No question yet, come back later. +