Allow corpus admins and element creators access to the thumbnail upload URL on folders
https://redmine.teklia.com/issues/6628
The thumbnail_put_url
attribute on elements, returned by RetrieveElement
, is currently only available when authenticated as a Ponos task on a process where generate_thumbnails
is enabled. This field will disappear soon, as the thumbnail generation task is replaced by a worker (arkindex/workers/thumbnails#2 (closed)). We should instead allow users with admin access to the element to update this thumbnail, and Ponos authentication is unnecessary.
Note that admin access to an element is not only admin access to a corpus. Admin access is granted to an element when you are either a corpus admin, or are both a corpus contributor and the element's creator.
Updating the existing ElementSlimSerializer.get_thumbnail_put_url
would require making extra queries on various other unrelated endpoints like AddSelection
, ListImageElements
, RetryProcess
, CreateProcess
, CreateFilesProcess
, StartProcess
, ApplyProcessTemplate
, RetrieveProcess
, UpdateProcess
, PartialUpdateProcess
, etc., but the thumbnail generator only relies on RetrieveElement
so this is all unnecessary.
We should move thumbnail_put_url
to the ElementSerializer
instead, which already has a rights
attribute. This removes a "thumbnail_put_url": null
from the aforementioned endpoints, and allows reusing the already fetched access level using a cached property.