diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 32fe25decdc..c4076e56b47 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -34,7 +34,7 @@ class WebsiteSurvey(http.Controller): @website.route(['/survey/', '/survey/list/'], type='http', auth='public', multilang=True) - def list_surveys(self, survey_id=None, page_id=None, **post): + def list_surveys(self, **post): '''All the public surveys''' cr, uid, context = request.cr, request.uid, request.context survey_obj = request.registry['survey.survey'] @@ -43,18 +43,29 @@ class WebsiteSurvey(http.Controller): surveys = survey_obj.browse(cr, uid, survey_ids, context=context) return request.website.render('survey.list', {'surveys': surveys}) - @website.route(["/survey/fill/id-/", - "/survey/fill/id-/page-"], + @website.route(["/survey/fill//", + "/survey/fill//page/", + "/survey/fill//page//"], type='http', auth='public', multilang=True) - def fill_survey(self, survey_id=None, page_id=None, **post): + def fill_survey(self, survey_id=None, page_index=None, **post): '''Display a survey''' cr, uid, context = request.cr, request.uid, request.context survey_obj = request.registry['survey.survey'] survey = survey_obj.browse(cr, uid, survey_id, context=context) - pagination = {'current': -1, 'next': -1} - # if not page_id: - # pagination['next'] = + pagination = {'current': -1, + 'next': 0} + if page_index is not None: + if page_index not in range(0, len(survey.page_ids)): + raise Exception("This page does not exist") + pagination['current'] = page_index + if page_index == len(survey.page_ids) - 1: + pagination['next'] = -1 + else: + pagination['next'] = page_index + 1 - return request.website.render('survey.survey', {'survey': survey, - 'pagination': pagination}) + return request.website.render('survey.survey', + {'survey': survey, + 'pagination': pagination, + 'debug': False, + 'validation_error': None}) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 1dc27138a59..478809e428a 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -77,7 +77,7 @@ class survey_survey(osv.osv): base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') for survey_browse in self.browse(cr, uid, ids, context=context): - res[survey_browse.id] = urljoin(base_url, "survey/fill/id-%s" + res[survey_browse.id] = urljoin(base_url, "survey/fill/%s/" % survey_browse.id) return res @@ -314,14 +314,7 @@ class survey_question(osv.osv): ''' Questions that will be asked in a survey. Each question can have one of more suggested answers (eg. in case of - dropdown choices, multi-answer checkboxes, radio buttons...) - - Changes - ------- - - This version of the model has been simplified in relation to the previous - one: some fields were simply a n-time repetition of a simpler field. It is - now allowed to have children question that allows to group subquestions.''' + dropdown choices, multi-answer checkboxes, radio buttons...).''' _name = 'survey.question' _description = 'Question' _rec_name = 'question' @@ -351,12 +344,10 @@ class survey_question(osv.osv): ('textbox', 'Text box'), ('numerical_box', 'Numerical box'), ('datetime', 'Date and Time'), - ('checkbox', 'Checkbox'), ('simple_choice_scale', 'One choice on a scale'), ('simple_choice_dropdown', 'One choice in a menu'), ('multiple_choice', 'Some choices in checkboxes'), - ('vector', - 'Multi-questions'), + ('vector', 'Multi-questions'), ('matrix', 'Matrix') ], 'Question Type', required=1), 'suggested_answers_ids': fields.one2many('survey.suggestion', diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index d6d2c55a08f..f670c825dc4 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -34,24 +34,28 @@
-
-

- - -
- -
-

-
+ +
+

+ + +
+ +
+

+
+
+ + + + + - - - - - +
@@ -64,123 +68,161 @@ - + + - - + + + + +