diff --git a/addons/web_linkedin/__init__.py b/addons/web_linkedin/__init__.py index 92b70f98cf8..88f4dc36398 100644 --- a/addons/web_linkedin/__init__.py +++ b/addons/web_linkedin/__init__.py @@ -1,2 +1,2 @@ -import res_config + import web_linkedin \ No newline at end of file diff --git a/addons/web_linkedin/__openerp__.py b/addons/web_linkedin/__openerp__.py index 680bef0c47b..122453d6096 100644 --- a/addons/web_linkedin/__openerp__.py +++ b/addons/web_linkedin/__openerp__.py @@ -9,8 +9,7 @@ This module provides the Integration of the LinkedIn with OpenERP. """, 'update_xml': [ - 'res_partner_view.xml', - 'res_config_view.xml', + 'web_linkedin_view.xml', ], "depends" : ["base"], "js": [ diff --git a/addons/web_linkedin/res_config.py b/addons/web_linkedin/res_config.py deleted file mode 100644 index 4678279f40e..00000000000 --- a/addons/web_linkedin/res_config.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (C) 2004-2012 OpenERP S.A. (). -# -# 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 . -# -############################################################################## - -from osv import osv, fields - -class base_config_settings(osv.osv_memory): - _inherit = 'base.config.settings' - _name = 'base.config.settings' - _columns = { - 'default_linkedin_api_key': fields.char('LinkedIn API key', size=128, default_model='res.company', - help="""Give API key of linkedin."""), - 'generate_key': fields.text('Go to URL', readonly=True, - help="""If you have not generate linkedin API Key yet than Go to URL to generate and enter it in above text field."""), - } - _defaults = { - 'generate_key': "To find contact persons from LinkedIn "\ - "\n====================================="\ - "\n* Go to this URL : https://www.linkedin.com/secure/developer "\ - "\n* Add New Application and fill the form,"\ - "\n - JavaScript API Domain is Your domain name (e.g. https://yourcompany.my.openerp.com),"\ - "\n - You can give multiple domain (e.g. yourcompany.my.openerp.com),"\ - "\n - programming tools is Javascript"\ - '\n* Copy the "API Key" and paste it in the field "LinkedIn API Key" here above.' - } - - def execute(self, cr, uid, ids, context=None): - super(base_config_settings,self).execute(cr, uid, ids, context=context) - company_obj = self.pool.get('res.company') - data = self.browse(cr, uid, ids[0], context=context) - company_id = company_obj._company_default_get(cr, uid, 'res.users', context=context) - company_obj.write(cr, uid, [company_id], {'linkedin_api_key': data.default_linkedin_api_key}, context=context) - -base_config_settings() - - diff --git a/addons/web_linkedin/res_config_view.xml b/addons/web_linkedin/res_config_view.xml deleted file mode 100644 index 991f637ec08..00000000000 --- a/addons/web_linkedin/res_config_view.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - General Settings - base.config.settings - - form - 20 - - - - - - - - - - - - - - - diff --git a/addons/web_linkedin/res_partner_view.xml b/addons/web_linkedin/res_partner_view.xml deleted file mode 100644 index de5d694c850..00000000000 --- a/addons/web_linkedin/res_partner_view.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/addons/web_linkedin/static/src/img/Linkedin_blue.png b/addons/web_linkedin/static/src/img/Linkedin_blue.png new file mode 100644 index 00000000000..c37d0218f7d Binary files /dev/null and b/addons/web_linkedin/static/src/img/Linkedin_blue.png differ diff --git a/addons/web_linkedin/static/src/js/linkedin.js b/addons/web_linkedin/static/src/js/linkedin.js index d1b163f45ad..d4dc2baf114 100644 --- a/addons/web_linkedin/static/src/js/linkedin.js +++ b/addons/web_linkedin/static/src/js/linkedin.js @@ -5,6 +5,72 @@ openerp.web_linkedin = function(instance) { var QWeb = instance.web.qweb; var _t = instance.web._t; - + + instance.web_linkedin.LinkedinTester = instance.web.Class.extend({ + init: function() { + this.api_key = "cxnr0l53n73x"; + this.linkedin_added = false; + this.linkedin_def = $.Deferred(); + }, + test_linkedin: function() { + var self = this; + return this.test_api_key().pipe(function() { + if (self.linkedin_added) + return self.linkedin_def.promise(); + var tag = document.createElement('script'); + tag.type = 'text/javascript'; + tag.src = "http://platform.linkedin.com/in.js"; + tag.innerHTML = 'api_key : ' + self.api_key + '\nauthorize : true'; + document.getElementsByTagName('head')[0].appendChild(tag); + linkedin_added = true; + $(tag).load(function() { + self.linkedin_def.resolve(); + }); + return self.linkedin_def.promise(); + }, function() { + /*return new instance.web.Model("ir.config_parameter").call("set_param", ["web.linkedin.apikey", "cxnr0l53n73x"]).pipe(function() { + return self.test_linkedin(); + });*/ + }); + }, + test_api_key: function() { + if (this.api_key) { + return $.when(); + } + return new instance.web.Model("ir.config_parameter").call("get_param", ["web.linkedin.apikey"]).pipe(function(a) { + if (a !== false) { + self.api_key = a; + return true; + } else { + return $.Deferred().reject(); + } + }); + }, + }); + + instance.web_linkedin.tester = new instance.web_linkedin.LinkedinTester(); + + instance.web_linkedin.Linkedin = instance.web.form.FieldChar.extend({ + init: function() { + this._super.apply(this, arguments); + var self = this; + this.display_dm = new instance.web.DropMisordered(true); + this.on("linkedin_loaded", this, function() { + $("input", self.$element).after(QWeb.render("FieldChar.linkedin")); + }); + }, + initialize_content: function() { + this._super(); + var self = this; + if (! this.get("effective_readonly")) { + this.display_dm.add(instance.web_linkedin.tester.test_linkedin()).then(function() { + self.trigger("linkedin_loaded"); + }); + } else { + this.display_dm.add($.when()); + } + }, + }); + instance.web.form.widgets.add('linkedin', 'instance.web_linkedin.Linkedin'); }; // vim:et fdc=0 fdl=0: diff --git a/addons/web_linkedin/static/src/xml/linkedin.xml b/addons/web_linkedin/static/src/xml/linkedin.xml index ff4d920d031..33ae10752fa 100644 --- a/addons/web_linkedin/static/src/xml/linkedin.xml +++ b/addons/web_linkedin/static/src/xml/linkedin.xml @@ -2,5 +2,7 @@ - + + Yop + \ No newline at end of file diff --git a/addons/web_linkedin/web_linkedin.py b/addons/web_linkedin/web_linkedin.py index 0cbb0b66ed0..4bb525db1ff 100644 --- a/addons/web_linkedin/web_linkedin.py +++ b/addons/web_linkedin/web_linkedin.py @@ -18,52 +18,5 @@ # along with this program. If not, see . # ############################################################################## -import base64 -import urllib2 -import xmlrpclib -import zlib -from web import common -openerpweb = common.http - -from osv import fields, osv - -class company(osv.osv): - _inherit = 'res.company' - _columns = { - 'linkedin_api_key': fields.char('LinkedIn API key', size=128), - } - -company() - -class users(osv.osv): - _inherit = 'res.users' - - def set_linkedin_api_key(self, cr, uid, key, context=None): - company_obj = self.pool.get('res.company') - company_id = company_obj._company_default_get(cr, uid, 'res.users', context=context) - company_obj.write(cr, uid, [company_id], {'linkedin_api_key': key }) - ir_values = self.pool.get('ir.values') - ir_values.set_default(cr, uid, 'res.company', 'linkedin_api_key', key) - - return True -users() - -class res_partner(osv.osv): - _inherit = 'res.partner' - - _columns = { - } - -res_partner() - -# don't know yet if I will remove it -class Binary(openerpweb.Controller): - _cp_path = "/web_linkedin/binary" - - @openerpweb.jsonrequest - def url2binary(self, req,url): - bfile = urllib2.urlopen(url) - return base64.b64encode(bfile.read()) - diff --git a/addons/web_linkedin/web_linkedin_view.xml b/addons/web_linkedin/web_linkedin_view.xml new file mode 100644 index 00000000000..b636722e2c7 --- /dev/null +++ b/addons/web_linkedin/web_linkedin_view.xml @@ -0,0 +1,21 @@ + + + + + res.partner.linkedin.inherit + res.partner + form + + + + + + + + + +