diff --git a/addons/live_support/include.html b/addons/live_support/include.html new file mode 100644 index 00000000000..bf761da4d1e --- /dev/null +++ b/addons/live_support/include.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/addons/live_support/live_support.py b/addons/live_support/live_support.py index 67b08a1987b..07eea5a853f 100644 --- a/addons/live_support/live_support.py +++ b/addons/live_support/live_support.py @@ -50,6 +50,19 @@ class ImportController(openerp.addons.web.http.Controller): return req.make_response(env.get_template("loader.js").render(info), headers=[('Content-Type', "text/javascript")]) + @openerp.addons.web.http.httprequest + def web_page(self, req, **kwargs): + p = json.loads(kwargs["p"]) + db = p["db"] + channel = p["channel"] + req.session._db = db + req.session._uid = None + req.session._login = "anonymous" + req.session._password = "anonymous" + script = req.session.model('live_support.channel').read(channel, ["script"])["script"] + return req.make_response(env.get_template("web_page.html").render({"script": script}), + headers=[('Content-Type', "text/html")]) + @openerp.addons.web.http.jsonrequest def available(self, req, db, channel): req.session._db = db @@ -71,10 +84,28 @@ class live_support_channel(osv.osv): break return res + def _script(self, cr, uid, ids, name, arg, context=None): + res = {} + for record in self.browse(cr, uid, ids, context=context): + res[record.id] = env.get_template("include.html").render({ + "url": self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), + "parameters": {"db":cr.dbname, "channel":record.id}, + }) + return res + + def _web_page(self, cr, uid, ids, name, arg, context=None): + res = {} + for record in self.browse(cr, uid, ids, context=context): + res[record.id] = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') + \ + "/live_support/web_page?p=" + json.dumps({"db":cr.dbname, "channel":record.id}) + return res + _columns = { 'name': fields.char(string="Name", size=200, required=True), 'user_ids': fields.many2many('im.user', 'live_support_channel_im_user', 'channel_id', 'user_id', string="Users"), 'are_you_inside': fields.function(_are_you_inside, type='boolean', string='Are you inside the matrix?', store=False), + 'script': fields.function(_script, type='text', string='Script', store=False), + 'web_page': fields.function(_web_page, type='url', string='Web Page', store=False, size="200"), } def get_available_user(self, cr, uid, channel_id, context=None): diff --git a/addons/live_support/live_support_view.xml b/addons/live_support/live_support_view.xml index cdcf5cb9e48..2617aa548d3 100644 --- a/addons/live_support/live_support_view.xml +++ b/addons/live_support/live_support_view.xml @@ -20,6 +20,10 @@

+