[IMP] web_widget_image_download: black, isort

This commit is contained in:
Alexandre Díaz
2020-01-30 17:50:13 +01:00
committed by manu
parent 720690c22a
commit 477a88bf48
5 changed files with 39 additions and 40 deletions

View File

@@ -1,31 +1,30 @@
/* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define('web_widget_image_download.widget', function (require) {
'use strict';
odoo.define("web_widget_image_download.widget", function(require) {
"use strict";
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
var FieldBinaryImage = require("web.basic_fields").FieldBinaryImage;
FieldBinaryImage.include({
_render: function () {
_render: function() {
this._super();
var $widget = this.$el.find('.o_form_binary_file_download');
this.imgSrc = this.$el.find('img[name="' + this.name + '"]')
.attr('src');
var $widget = this.$el.find(".o_form_binary_file_download");
this.imgSrc = this.$el.find('img[name="' + this.name + '"]').attr("src");
$.ajax({
type: 'HEAD', // Avoid downloading full image, just headers
// Avoid downloading full image, just headers
type: "HEAD",
url: this.imgSrc,
complete: function (xhr) {
complete: function(xhr) {
$widget.attr(
'download',
xhr.getResponseHeader("Content-Type")
.replace('/', '.')
"download",
xhr.getResponseHeader("Content-Type").replace("/", ".")
);
}
},
});
$widget.attr('href', this.imgSrc);
}
$widget.attr("href", this.imgSrc);
},
});
});