Added loading of images

bzr revid: nicolas.vanhoren@openerp.com-20120806140925-2i8o7wla0tfgfdsj
This commit is contained in:
niv-openerp 2012-08-06 16:09:25 +02:00
parent 5199287394
commit 00cbc1d84f
2 changed files with 28 additions and 1 deletions

View File

@ -82,13 +82,29 @@ openerp.web_linkedin = function(instance) {
});
},
selected_entity: function(entity) {
var self = this;
var to_change = {};
var defs = [];
if (entity.__type === "company") {
to_change.name = entity.name;
if (entity.logoUrl) {
defs.push(self.rpc('/web_linkedin/binary/url2binary',
{'url': entity.logoUrl}).pipe(function(data){
to_change.photo = data;
}));
}
} else { //people
to_change.name = _.str.sprintf("%s %s", entity.firstName, entity.lastName);
if (entity.pictureUrl) {
defs.push(self.rpc('/web_linkedin/binary/url2binary',
{'url': entity.pictureUrl}).pipe(function(data){
to_change.photo = data;
}));
}
}
this.view.on_processed_onchange({value:to_change});
$.when.apply($, defs).then(function() {
self.view.on_processed_onchange({value:to_change});
});
},
});

View File

@ -19,4 +19,15 @@
#
##############################################################################
import web.common.http
import base64
import urllib2
class Binary(web.common.http.Controller):
_cp_path = "/web_linkedin/binary"
@web.common.http.jsonrequest
def url2binary(self, req,url):
bfile = urllib2.urlopen(url)
return base64.b64encode(bfile.read())