From 9f964ca29d1fbf334c8bde793936822a2d1cddd7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 14 Oct 2011 11:43:24 +0200 Subject: [PATCH] [IMP] share: share_url_template is read from ir_config_parameter bzr revid: chs@openerp.com-20111014094324-wpj3265vwinel3rj --- addons/share/static/src/js/share.js | 2 -- addons/share/wizard/share_wizard.py | 17 ++++++++++------- addons/share/wizard/share_wizard_view.xml | 2 -- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js index 96ff5dc4dd6..68df8eec878 100644 --- a/addons/share/static/src/js/share.js +++ b/addons/share/static/src/js/share.js @@ -17,14 +17,12 @@ instance.web.Sidebar = instance.web.Sidebar.extend({ var view = this.widget_parent var action = view.widget_parent.action; - var share_url_template = _('%s//%s/?db=%%(dbname)s&login=%%(login)s').sprintf(document.location.protocol, document.location.host); var Share = new instance.web.DataSet(this, 'share.wizard', view.dataset.get_context()); Share.create({ name: action.name, domain: view.dataset.domain, action_id: action.id, - share_url_template: share_url_template, }, function(result) { var share_id = result.result; console.log('share_id', share_id); diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 20f175b1e0b..1cd8104100c 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -119,12 +119,18 @@ class share_wizard(osv.osv_memory): values['name'] = action.name return super(share_wizard,self).create(cr, uid, values, context=context) + def share_url_template(self, cr, uid, _ids, context=None): + # NOTE: take _ids in parameter to allow usage through browse_record objects + base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='', context=context) + if base_url: + base_url += '/?db=%(dbname)s&login=%(login)s' + return base_url def _share_root_url(self, cr, uid, ids, _fieldname, _args, context=None): result = dict.fromkeys(ids, '') - data = dict(dbname=cr.dbname, login='', password='') + data = dict(dbname=cr.dbname, login='') for this in self.browse(cr, uid, ids, context=context): - result[this.id] = this.share_url_template % data + result[this.id] = this.share_url_template() % data return result _columns = { @@ -137,8 +143,6 @@ class share_wizard(osv.osv_memory): 'access_mode': fields.selection([('readonly','Can view'),('readwrite','Can edit')],'Access Mode', required=True, help="Access rights to be granted on the shared documents."), 'result_line_ids': fields.one2many('share.wizard.result.line', 'share_wizard_id', 'Summary', readonly=True), - 'share_url_template': fields.char('Share Access URL Template', size=512, - help='Template for share url. May contains %(dbname)s, %(login)s and %(password)s'), 'share_root_url': fields.function(_share_root_url, string='Share Access URL', type='char', size=512, readonly=True, help='Main access page for users that are granted shared access'), 'name': fields.char('Share Title', size=64, required=True, help="Title for the share (displayed to users as menu and shortcut name)"), @@ -147,7 +151,6 @@ class share_wizard(osv.osv_memory): _defaults = { 'user_type' : 'emails', 'domain': lambda self, cr, uid, context, *a: context.get('domain', '[]'), - 'share_url_template': lambda self, cr, uid, context, *a: context.get('share_url_template') or _('Please specify "share_url_template" in context'), 'action_id': lambda self, cr, uid, context, *a: context.get('action_id'), 'access_mode': 'readonly', } @@ -735,8 +738,8 @@ class share_result_line(osv.osv_memory): def _share_url(self, cr, uid, ids, _fieldname, _args, context=None): result = dict.fromkeys(ids, '') for this in self.browse(cr, uid, ids, context=context): - data = dict(dbname=cr.dbname, login=this.login, password='') # password is kept empty for security reasons - result[this.id] = this.share_wizard_id.share_url_template % data + data = dict(dbname=cr.dbname, login=this.login) + result[this.id] = this.share_wizard_id.share_url_template() % data return result _columns = { diff --git a/addons/share/wizard/share_wizard_view.xml b/addons/share/wizard/share_wizard_view.xml index dedb7c7f4bc..128b32b07da 100644 --- a/addons/share/wizard/share_wizard_view.xml +++ b/addons/share/wizard/share_wizard_view.xml @@ -82,7 +82,6 @@ - 'action_id' (id of action) - 'domain' (string expression for full domain to apply as sent to server, with dynamic data like 'uid' replaced by actual value (i.e. after eval)!) - - 'share_url_template' : URL for direct access to share page (may include %(login)s and %(password)s placeholders) --> Share Wizard @@ -98,7 +97,6 @@ - 'action_id' (id of action) - 'domain' (string expression for full domain to apply as sent to server, with dynamic data like 'uid' replaced by actual value (i.e. after eval)!) - - 'share_url_template' : URL for direct access to share page (may include %(login)s and %(password)s placeholders) --> Share Wizard