From ecb636c67c0cab1c312b3f43a62ca8359115ef5d Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Wed, 19 Mar 2014 15:29:52 +0100 Subject: [PATCH] [FIX] URL slugs mess... bzr revid: rim@openerp.com-20140319142952-2wzi0fvzvopx9lmy --- addons/survey/controllers/main.py | 4 ++-- addons/survey/survey.py | 24 +++++++++++++------ addons/survey/views/survey_result.xml | 6 ++--- addons/survey/views/survey_templates.xml | 8 +++---- .../wizard/survey_email_compose_message.py | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 076e67aec62..15a4003c1ac 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -272,8 +272,8 @@ class WebsiteSurvey(http.Controller): return json.dumps(ret) # Printing routes - @http.route(['/survey/print//', - '/survey/print///'], + @http.route(['/survey/print/', + '/survey/print//'], type='http', auth='user', multilang=True, website=True) def print_survey(self, survey, token=None, **post): '''Display an survey in printable view; if is set, it will diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 091cf0745d1..0b98eb1ede5 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -22,6 +22,7 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF +from openerp.addons.website.models.website import slug from urlparse import urljoin import datetime @@ -92,19 +93,28 @@ class survey_survey(osv.Model): """ Computes a public URL for the survey """ base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - return {id: urljoin(base_url, "survey/start/%s/" % id) for id in ids} + res = {} + for survey in self.browse(cr, uid, ids, context=context): + res[survey.id] = urljoin(base_url, "survey/start/%s" % slug(survey)) + return res def _get_print_url(self, cr, uid, ids, name, arg, context=None): """ Computes a printing URL for the survey """ base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - return {id: urljoin(base_url, "survey/print/%s/" % id) for id in ids} + res = {} + for survey in self.browse(cr, uid, ids, context=context): + res[survey.id] = urljoin(base_url, "survey/print/%s" % slug(survey)) + return res def _get_result_url(self, cr, uid, ids, name, arg, context=None): """ Computes an URL for the survey results """ base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - return {id: urljoin(base_url, "survey/results/%s/" % id) for id in ids} + res = {} + for survey in self.browse(cr, uid, ids, context=context): + res[survey.id] = urljoin(base_url, "survey/results/%s" % slug(survey)) + return res # Model fields # @@ -254,7 +264,7 @@ class survey_survey(osv.Model): ''' Open the website page with the survey form ''' trail = "" if context and 'survey_token' in context: - trail = context['survey_token'] + "/" + trail = "/" + context['survey_token'] return { 'type': 'ir.actions.act_url', 'name': "Start Survey", @@ -303,7 +313,7 @@ class survey_survey(osv.Model): ''' Open the website page with the survey printable view ''' trail = "" if context and 'survey_token' in context: - trail = context['survey_token'] + "/" + trail = "/" + context['survey_token'] return { 'type': 'ir.actions.act_url', 'name': "Print Survey", @@ -326,7 +336,7 @@ class survey_survey(osv.Model): 'type': 'ir.actions.act_url', 'name': "Results of the Survey", 'target': 'self', - 'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + "phantom/" + 'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + "/phantom" } @@ -797,7 +807,7 @@ class survey_user_input(osv.Model): 'type': 'ir.actions.act_url', 'name': "View Answers", 'target': 'self', - 'url': '%s%s/' % (user_input['print_url'], user_input['token']) + 'url': '%s/%s' % (user_input['print_url'], user_input['token']) } def action_survey_results(self, cr, uid, ids, context=None): diff --git a/addons/survey/views/survey_result.xml b/addons/survey/views/survey_result.xml index 2577077d132..a5113df25e3 100644 --- a/addons/survey/views/survey_result.xml +++ b/addons/survey/views/survey_result.xml @@ -76,7 +76,7 @@

- Print respondent's answers
+ Print respondent's answers
@@ -85,7 +85,7 @@

- Print respondent's answers
+ Print respondent's answers
@@ -94,7 +94,7 @@
- Print respondent's answers
+ Print respondent's answers
diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index 0430969bbd3..312d3b4ac3d 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -31,7 +31,7 @@

Thank you!

You scored points.
-
If you wish, you can print your answers.
+
If you wish, you can print your answers.
@@ -61,7 +61,7 @@

@@ -95,7 +95,7 @@
-
+ @@ -257,7 +257,7 @@

- +