(backend) add max ancestors role field to document access endpoint

This field is set only on the list view when all accesses for a given
document and all its ancestors are listed. It gives the highest role
among all accesses related to each document.
This commit is contained in:
Samuel Paccoud - DINUM
2025-05-02 19:18:30 +02:00
committed by Anthony LC
parent f782a0236b
commit 1ab237af3b
5 changed files with 291 additions and 17 deletions

View File

@@ -1140,7 +1140,9 @@ class DocumentAccess(BaseAccess):
set_role_to.append(RoleChoices.OWNER)
# Filter out roles that would be lower than the one the user already has
ancestors_role_priority = RoleChoices.get_priority(ancestors_role)
ancestors_role_priority = RoleChoices.get_priority(
getattr(self, "max_ancestors_role", None)
)
set_role_to = [
candidate_role
for candidate_role in set_role_to