[ADD] Add Cache-Control support in Binary Image and kanban view

bzr revid: fme@openerp.com-20120619090642-o397qwkzanof1b04
This commit is contained in:
Fabien Meghazi 2012-06-19 11:06:42 +02:00
parent 682f5cbe87
commit d148034070
2 changed files with 10 additions and 1 deletions

View File

@ -1358,6 +1358,11 @@ class Binary(openerpweb.Controller):
image_data = self.placeholder(req)
headers.append(('ETag', retag))
headers.append(('Content-Length', len(image_data)))
try:
ncache = int(kw.get('cache'))
headers.append(('Cache-Control', 'no-cache' if ncache == 0 else 'max-age=%s' % (ncache)))
except:
pass
return req.make_response(image_data, headers)
def placeholder(self, req):
addons_path = openerpweb.addons_manifest['web']['addons_path']

View File

@ -740,9 +740,13 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
var email_md5 = $.md5(email);
return 'http://www.gravatar.com/avatar/' + email_md5 + '.png?s=' + size + '&d=' + default_;
},
kanban_image: function(model, field, id) {
kanban_image: function(model, field, id, cache) {
id = id || '';
var url = instance.connection.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
if (cache !== undefined) {
// Set the cache duration in seconds.
url += '&cache=' + parseInt(cache, 10);
}
return url;
},
kanban_text_ellipsis: function(s, size) {