wip
bzr revid: nicolas.vanhoren@openerp.com-20130205151506-gqy3b1900dsbu1lt
This commit is contained in:
parent
57a6d0625e
commit
86db332967
|
@ -0,0 +1,2 @@
|
|||
<script type="text/javascript" src="{{url}}/live_support/static/ext/static/js/require.js"></script>
|
||||
<script type="text/javascript" src='{{url}}/live_support/loader?p={{parameters | json}}'></script>
|
|
@ -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):
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
<h1>
|
||||
<field name="name"/>
|
||||
</h1>
|
||||
<!--
|
||||
<label for="web_page" colspan="2"/>
|
||||
<field name="web_page" readonly="1" nolabel="1" colspan="2"/>
|
||||
-->
|
||||
<div style="margin-bottom: 12px">
|
||||
<button type="object" name="join" string="Join" attrs='{"invisible": [["are_you_inside", "=", True]]}'/>
|
||||
<button type="object" name="quit" string="Quit" attrs='{"invisible": [["are_you_inside", "=", False]]}'/>
|
||||
|
@ -27,6 +31,8 @@
|
|||
<field name="are_you_inside" invisible="1"/>
|
||||
<label for="user_ids" colspan="2"/>
|
||||
<field name="user_ids" readonly="1" nolabel="1" colspan="2"/>
|
||||
<label for="script" colspan="2"/>
|
||||
<field name="script" readonly="1" nolabel="1" colspan="2"/>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_ls_chann1,live_support.channel,model_live_support_channel,,1,0,0,0
|
||||
access_ls_chann2,live_support.channel,model_live_support_channel,group_live_support,1,1,1,1
|
||||
access_ls_chann2,live_support.channel,model_live_support_channel,group_live_support,1,1,1,0
|
||||
access_ls_message,live_support.im.message,web_im.model_im_message,portal.group_anonymous,0,0,0,0
|
||||
access_im_user,live_support.im.user,web_im.model_im_user,portal.group_anonymous,1,0,0,0
|
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{{script}}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue