[IMP] mail_preview_base: black, isort, prettier

This commit is contained in:
Jaime Arroyo 2020-09-28 11:55:04 +02:00 committed by Jasmin Solanki
parent 139c59c31c
commit e6acf6eaac
2 changed files with 33 additions and 29 deletions

View File

@ -2,14 +2,14 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
'name': 'Mail Preview',
'summary': """
"name": "Mail Preview",
"summary": """
Base to add more previewing options""",
'version': '12.0.1.0.0',
'license': 'LGPL-3',
'author': 'Creu Blanca,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/social',
'depends': ['mail'],
'data': ['template/assets.xml'],
'qweb': ['static/src/xml/preview.xml'],
"version": "13.0.1.0.0",
"license": "LGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"depends": ["mail"],
"data": ["template/assets.xml"],
"qweb": ["static/src/xml/preview.xml"],
}

View File

@ -16,19 +16,21 @@ odoo.define("mail_preview_base.preview", function(require) {
this._super.apply(this, arguments);
var self = this;
_.forEach(this.attachment, function (attachment) {
if (attachment.mimetype === 'application/pdf' || attachment.type === 'text') {
if (attachment.mimetype === 'application/pdf' ||
attachment.type === 'text'
) {
attachment.source_url = self._getContentUrl(attachment);
} else {
attachment.source_url = self._getImageUrl(attachment);
}
else {
attachment.source_url = self._getImageUrl(attachment)
}
})
});
this.attachment = this.attachment.concat(
_.filter(attachments, function (attachment) {
return self._checkAttachment(attachment)
return self._checkAttachment(attachment);
})
);
},
/*
This function is a hook, it will allow to define new kind of
records
@ -44,7 +46,9 @@ odoo.define("mail_preview_base.preview", function(require) {
return "/web/image/" + attachment.id;
},
_hasPreview: function (type, attachment) {
return type === 'image' || type === 'video' || attachment.mimetype === 'application/pdf';
return type === 'image' ||
type === 'video' ||
attachment.mimetype === 'application/pdf';
},
});
@ -53,11 +57,11 @@ odoo.define("mail_preview_base.preview", function(require) {
_.each(attachments, function (attachment) {
attachment.has_preview = DocumentViewer.prototype._hasPreview(
attachment.mimetype && attachment.mimetype.split('/').shift(),
attachment)
})
attachment);
});
this._super.apply(this, arguments);
},
})
});
var FieldPreviewViewer = DocumentViewer.extend({
init: function (parent, attachments, activeAttachmentID, model, field) {
@ -81,16 +85,16 @@ odoo.define("mail_preview_base.preview", function(require) {
_getContentUrl: function (attachment) {
return "/web/content/" +
this.modelName + '/' +
attachment.id + '/'
+ this.fieldName
+"?filename=" +
attachment.id + '/' +
this.fieldName +
"?filename=" +
window.encodeURIComponent(attachment.name);
},
_getImageUrl: function (attachment) {
return "/web/image/" +
this.modelName + '/' +
attachment.id + '/'
+ this.fieldName
attachment.id + '/' +
this.fieldName;
},
});