summaryrefslogtreecommitdiff
path: root/addons/web_livechat
diff options
context:
space:
mode:
authorrpa (Open ERP) <rpa@tinyerp.com>2010-12-20 13:52:55 +0530
committerrpa (Open ERP) <rpa@tinyerp.com>2010-12-20 13:52:55 +0530
commit4e307d022c8fbdba848b8a4f57d668a4b6bd036f (patch)
tree249f8361bac695c0bec0c844d964194202d680a0 /addons/web_livechat
parent6e34e7c52a3f37876b627fb5c80ac79d3c614807 (diff)
parentc2f85df411949653257c5b51f1578a1e40709510 (diff)
[MERGE]: Merge with lp:openobject-addons
bzr revid: rpa@tinyerp.com-20101215042654-04ccazkz5v57ml3j bzr revid: rpa@tinyerp.com-20101216043335-ji5h61dra451cml4 bzr revid: rpa@tinyerp.com-20101220082255-1g3ea50rkjlacwqw
Diffstat (limited to 'addons/web_livechat')
-rw-r--r--addons/web_livechat/LICENSE15
-rw-r--r--addons/web_livechat/__init__.py20
-rw-r--r--addons/web_livechat/__openerp__.py34
-rw-r--r--addons/web_livechat/publisher_warranty.py38
-rw-r--r--addons/web_livechat/web/__init__.py5
-rw-r--r--addons/web_livechat/web/editors.py94
-rw-r--r--addons/web_livechat/web/static/css/lc.css7
7 files changed, 213 insertions, 0 deletions
diff --git a/addons/web_livechat/LICENSE b/addons/web_livechat/LICENSE
new file mode 100644
index 00000000000..27a1a4cf453
--- /dev/null
+++ b/addons/web_livechat/LICENSE
@@ -0,0 +1,15 @@
+OpenERP, Open Source Management Solution
+Copyright © 2010 OpenERP SA (<http://openerp.com>).
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public Lice
+along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/addons/web_livechat/__init__.py b/addons/web_livechat/__init__.py
new file mode 100644
index 00000000000..9af39b2f58c
--- /dev/null
+++ b/addons/web_livechat/__init__.py
@@ -0,0 +1,20 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import publisher_warranty
diff --git a/addons/web_livechat/__openerp__.py b/addons/web_livechat/__openerp__.py
new file mode 100644
index 00000000000..d744a16dd65
--- /dev/null
+++ b/addons/web_livechat/__openerp__.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+ 'name': 'Live Chat Support',
+ 'version': '1.0',
+ 'category': 'Generic Modules/Others',
+ 'description': "Enable live chat support for whom have a maintenance contract",
+ 'author': 'OpenERP s.a.',
+ 'website': 'http://openerp.com',
+ 'depends': ['base'],
+ 'update_xml': [],
+ 'installable': True,
+ 'active': True,
+ 'web': True,
+ 'certificate': '0013762192410413',
+}
diff --git a/addons/web_livechat/publisher_warranty.py b/addons/web_livechat/publisher_warranty.py
new file mode 100644
index 00000000000..b4825febcf6
--- /dev/null
+++ b/addons/web_livechat/publisher_warranty.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv
+from tools import cache
+
+class publisher_warranty_contract(osv.osv):
+ _inherit = 'publisher_warranty.contract'
+
+ @cache(skiparg=3, timeout=300)
+ def is_livechat_enable(self, cr, uid):
+ domain = [('state', '=', 'valid'), ('kind', '=', 'support')]
+ return self.search_count(cr, uid, domain) != 0
+
+ @cache(skiparg=3)
+ def get_default_livechat_text(self, cr, uid):
+ return '<a href="http://www.openerp.com/services/subscribe-onsite" target="_blank"><img src="/web_livechat/static/images/busy.png"/>Online Support</a>'
+
+publisher_warranty_contract()
+
diff --git a/addons/web_livechat/web/__init__.py b/addons/web_livechat/web/__init__.py
new file mode 100644
index 00000000000..ec026b194f1
--- /dev/null
+++ b/addons/web_livechat/web/__init__.py
@@ -0,0 +1,5 @@
+##############################################################################
+# This file is part of the "web-livechatinc-odoo" OpenERP module.
+# See LICENCE file at the root of the module folder.
+##############################################################################
+import editors
diff --git a/addons/web_livechat/web/editors.py b/addons/web_livechat/web/editors.py
new file mode 100644
index 00000000000..9b653312415
--- /dev/null
+++ b/addons/web_livechat/web/editors.py
@@ -0,0 +1,94 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import openobject.templating
+
+class BaseTemplateEditor(openobject.templating.TemplateEditor):
+ templates = ['/openobject/controllers/templates/base.mako']
+
+ def edit(self, template, template_text):
+ output = super(BaseTemplateEditor, self).edit(template, template_text)
+
+ end_head = output.index('</head>')
+
+ output = output[:end_head] + """
+ <link rel="stylesheet" type="text/css" href="/web_livechat/static/css/lc.css"/>
+ <%
+ if 'livechat' not in cp.session:
+ cp.session['livechat'] = rpc.session.execute('object', 'execute', 'publisher_warranty.contract', 'is_livechat_enable')
+ %>
+ % if cp.session['livechat']:
+<script type="text/javascript">
+
+ (function() {
+ var lc_params = '';
+ var lc_lang = 'en';
+ var lc_skill = '0';
+
+ var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
+ var lc_src = ('https:' == document.location.protocol ? 'https://' : 'http://');
+ lc_src += 'chat.livechatinc.net/licence/1035052/script.cgi?lang='+lc_lang+unescape('%26')+'groups='+lc_skill;
+ lc_src += ((lc_params == '') ? '' : unescape('%26')+'params='+encodeURIComponent(encodeURIComponent(lc_params))); lc.src = lc_src;
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
+ })();
+
+</script>
+ % endif
+ """ + output[end_head:]
+
+ return output
+
+
+class HeaderTemplateEditor(openobject.templating.TemplateEditor):
+ templates = ['/openerp/controllers/templates/header.mako']
+
+
+ def edit(self, template, template_text):
+ output = super(HeaderTemplateEditor, self).edit(template, template_text)
+
+ PATTERN = '<div id="corner">'
+ corner = output.index(PATTERN) + len(PATTERN)
+
+
+ output = output[:corner] + """
+ <p id="livechat_status" class="logout">
+ ${ rpc.session.execute('object', 'execute', 'publisher_warranty.contract', 'get_default_livechat_text') | n}
+ </p>
+ % if cp.session['livechat']:
+
+ <script type="text/javascript">
+ var __lc_buttons = __lc_buttons || [];
+ __lc_buttons.push({
+ elementId: 'livechat_status',
+ language: 'en',
+ skill: '0',
+ type: 'text',
+ labels: {
+ online: '<img src="/web_livechat/static/images/available.png"/>Online Support',
+ offline: '<img src="/web_livechat/static/images/away.png"/>Online Support'
+ }
+ });
+ </script>
+
+ % endif
+ """ + output[corner:]
+ return output
+
diff --git a/addons/web_livechat/web/static/css/lc.css b/addons/web_livechat/web/static/css/lc.css
new file mode 100644
index 00000000000..e6892857ddd
--- /dev/null
+++ b/addons/web_livechat/web/static/css/lc.css
@@ -0,0 +1,7 @@
+#livechat_status a.online {
+ text-shadow: 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404;
+}
+#livechat_status img {
+ vertical-align: middle;
+ margin-right: 0.5em;
+}