[FIX] URL slugs mess...
bzr revid: rim@openerp.com-20140319142952-2wzi0fvzvopx9lmy
This commit is contained in:
parent
a674b47980
commit
ecb636c67c
|
@ -272,8 +272,8 @@ class WebsiteSurvey(http.Controller):
|
|||
return json.dumps(ret)
|
||||
|
||||
# Printing routes
|
||||
@http.route(['/survey/print/<model("survey.survey"):survey>/',
|
||||
'/survey/print/<model("survey.survey"):survey>/<string:token>/'],
|
||||
@http.route(['/survey/print/<model("survey.survey"):survey>',
|
||||
'/survey/print/<model("survey.survey"):survey>/<string:token>'],
|
||||
type='http', auth='user', multilang=True, website=True)
|
||||
def print_survey(self, survey, token=None, **post):
|
||||
'''Display an survey in printable view; if <token> is set, it will
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<span t-field="user_input.value_free_text"></span><br/>
|
||||
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p></small>
|
||||
<span class="pull-right">
|
||||
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
<a t-att-href="user_input.user_input_id.print_url+'/'+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
</span>
|
||||
</td>
|
||||
</t>
|
||||
|
@ -85,7 +85,7 @@
|
|||
<span t-field="user_input.value_text"></span><br/>
|
||||
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p>
|
||||
<span class="pull-right">
|
||||
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
<a t-att-href="user_input.user_input_id.print_url+'/'+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
</span>
|
||||
</small>
|
||||
</td>
|
||||
|
@ -94,7 +94,7 @@
|
|||
<td>
|
||||
<span class="oe_date" t-field="user_input.value_date"></span><br/>
|
||||
<span class="pull-right">
|
||||
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
<a t-att-href="user_input.user_input_id.print_url+'/'+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
|
||||
</span>
|
||||
</td>
|
||||
</t>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<h1>Thank you!</h1>
|
||||
<div t-field="survey.thank_you_message" />
|
||||
<div t-if='survey.quizz_mode'>You scored <t t-esc="user_input.quizz_score" /> points.</div>
|
||||
<div>If you wish, you can <a t-att-href="'/survey/print/%s/%s' % (survey.id, token)">print your answers</a>.</div>
|
||||
<div>If you wish, you can <a t-att-href="'/survey/print/%s/%s' % (slug(survey), token)">print your answers</a>.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<div class='jumbotron mt32'>
|
||||
<h1 t-field='survey.title' />
|
||||
<div t-field='survey.description' />
|
||||
<a class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (survey.id, token)">
|
||||
<a class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (slug(survey), token)">
|
||||
Start Survey
|
||||
</a>
|
||||
</div>
|
||||
|
@ -95,7 +95,7 @@
|
|||
<div t-field='page.description'/>
|
||||
</div>
|
||||
|
||||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s_%s' % (survey.id, page.id)" t-att-action="'/survey/fill/%s/%s' % (survey.id, token)" t-att-data-prefill="'/survey/prefill/%s/%s/%s' % (survey.id, token, page.id)" t-att-data-validate="'/survey/validate/%s' % (survey.id)" t-att-data-submit="'/survey/submit/%s' % (survey.id)">
|
||||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s_%s' % (survey.id, page.id)" t-att-action="'/survey/fill/%s/%s' % (slug(survey), token)" t-att-data-prefill="'/survey/prefill/%s/%s/%s' % (slug(survey), token, slug(page))" t-att-data-validate="'/survey/validate/%s' % (slug(survey))" t-att-data-submit="'/survey/submit/%s' % (slug(survey))">
|
||||
<input type="hidden" name="page_id" t-att-value="page.id" />
|
||||
<input type="hidden" name="token" t-att-value="token" />
|
||||
<t t-foreach='page.question_ids' t-as='question'>
|
||||
|
@ -257,7 +257,7 @@
|
|||
<h1><span t-field='survey.title'/></h1>
|
||||
<t t-if="survey.description is not False"><div t-field='survey.description'/></t>
|
||||
</div>
|
||||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (survey.id, token)">
|
||||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)">
|
||||
<t t-foreach="survey.page_ids" t-as="page">
|
||||
<div class="page-header">
|
||||
<h1 t-field='page.title' />
|
||||
|
|
|
@ -138,7 +138,7 @@ class survey_mail_compose_message(osv.TransientModel):
|
|||
#set url
|
||||
url = wizard.survey_id.public_url
|
||||
if token:
|
||||
url = url + token
|
||||
url = url + '/' + token
|
||||
# post the message
|
||||
values = {
|
||||
'model': None,
|
||||
|
|
Loading…
Reference in New Issue