summaryrefslogtreecommitdiff
path: root/addons/web_unsplash
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2019-06-04 15:11:08 +0200
committerSébastien Theys <seb@odoo.com>2019-06-04 22:14:13 +0200
commit76cf2ae82a45b9ffcf63b524944a42b7f5192b0c (patch)
tree89540178c9e62def90377eb50ea8f7e1c089aff6 /addons/web_unsplash
parent191c556d6b50b35178ea5bb91fb998bcffb86367 (diff)
[IMP] web_editor, *: improve media dialog attachment upload
* = web_unsplash, website Remove iframe upload and replace it with a proper RPC. The route is now only accepting one file at a time, which makes it easier to maintain, and allows to process the first file as soon as it is ready, instead of having to wait on everything. Also fix a bug where a document could not be uploaded because it would try to parse it as an image. Remove filter after search result from the JS and add the corresponding conditions in the domain to avoid processing and returning unnecessary records. If multiple attachments exist with the same URL, now display them all to avoid confusion. Compute all the necessary values in the python model instead of in the JS. Allow SVG in the widget (the server already accepted them before). Disable multiple image upload when not in multiImages mode. task-1930726 PR: #31208
Diffstat (limited to 'addons/web_unsplash')
-rw-r--r--addons/web_unsplash/controllers/main.py4
-rw-r--r--addons/web_unsplash/static/src/js/unsplash_image_widget.js4
2 files changed, 2 insertions, 6 deletions
diff --git a/addons/web_unsplash/controllers/main.py b/addons/web_unsplash/controllers/main.py
index c9a2deb631e..98b3cec976e 100644
--- a/addons/web_unsplash/controllers/main.py
+++ b/addons/web_unsplash/controllers/main.py
@@ -97,7 +97,7 @@ class Web_Unsplash(http.Controller):
logger.exception("Timeout: " + str(e))
continue
- image_base64 = tools.image_process(image_base64)
+ image_base64 = tools.image_process(image_base64, verify_resolution=True)
mimetype = guess_mimetype(base64.b64decode(image_base64))
# append image extension in name
query += mimetypes.guess_extension(mimetype) or ''
@@ -116,7 +116,7 @@ class Web_Unsplash(http.Controller):
'res_model': res_model,
})
attachment.generate_access_token()
- uploads.extend(attachment.read(['name', 'mimetype', 'checksum', 'url', 'type', 'res_id', 'res_model', 'access_token']))
+ uploads.append(attachment._get_media_info())
# Notifies Unsplash from an image download. (API requirement)
self._notify_download(value.get('download_url'))
diff --git a/addons/web_unsplash/static/src/js/unsplash_image_widget.js b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
index 53259e6278b..8244f12b4b9 100644
--- a/addons/web_unsplash/static/src/js/unsplash_image_widget.js
+++ b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
@@ -92,10 +92,6 @@ widgetsMedia.ImageWidget.include({
query: self._unsplash.query,
}
}).then(function (images) {
- _.each(images, function (image) {
- image.src = image.url;
- image.isDocument = !(/gif|jpe|jpg|png/.test(image.mimetype));
- });
self.attachments = images;
self.selectedAttachments = images;
return _super.apply(self, args);