Open babastienne opened 1 year ago
Patch coverage: 46.66%
and project coverage change: -0.28%
:warning:
Comparison is base (
2f04b5b
) 89.08% compared to head (ef724aa
) 88.80%.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Nice. I had in mind since a long time to activate upload features in Tinymce to make it a lot easier for user to include their images into static pages. 👍 Maybe we should not put "tinymce" in the file path, to have something more generic like "media/uploads/uuid/.."
Better way to achieve this is to create an attachment to keep naming / categorization logic and possibility to delete it if required
To me there will be just a few images uploaded in the WYSIWYG, so it is not crucial to have an orphan deletion mechanism.
In classical CMS, there are thousands of images uploaded in articles and no automatic system to delete unused ones.
So in our case it is secondary as most images are uploaded as objects attachments, and it shouldn't block this PR in my opinion.
The use of Attachment model to support the TinyMCE image upload should be considered for the following reasons:
But using Attachment is not straightforward as an instance ID is needed to create an Attachment so we cannot create it when an image is uploaded on the form to create a new entity.
We could create temporary files/attachments in the image_upload
handler and create the real Attachement on saving after form validation on the Django side.
Another concern is the absolute URLs which are inserted in the tinymce HTML content. When GTA server configuration changes (for instance with a new domain) all those URLs will be broken.
Demonstration of the feature :
mapentity.webm
The local media will be imported into MEDIA_ROOT folder and automatically added to the text area.
Files are store in the media folder and then into the following path :
/tinymce/<generated-uuid>/file.ext
. The generated uuid allow to avoid conflicts if multiple files with the same name are uploaded.Everything seems to be working fine.
By default TinyMCE stored a relative path for the uploaded files. I ensure the URL stored for local files are absolute urls therefore GTR3 and others services can exploit data without having to rebuild URLs and API V2 from Geotrek needs no modification either.
One important element not done in this PR: The uploaded files are stored into media but there is no method to delete them if there not used anymore. I'd like some help to find the best strategy to find and remove unused uploaded file. A command that users will need to run ? An asynchrone task ? How can we determine which files are not used ?