(back) accept for a owner the request to access a document

Add the action accepting a request to access a document. It is possible
to override the role from the request and also update an existing
DocumentAccess
This commit is contained in:
Manuel Raynaud
2025-06-18 15:50:12 +02:00
parent c2e46fa9e2
commit d33286019c
4 changed files with 212 additions and 2 deletions

View File

@@ -1205,8 +1205,22 @@ class DocumentAskForAccess(BaseModel):
"update": is_admin_or_owner,
"partial_update": is_admin_or_owner,
"retrieve": is_admin_or_owner,
"accept": is_admin_or_owner,
}
def accept(self, role=None):
"""Accept a document ask for access resource."""
if role is None:
role = self.role
DocumentAccess.objects.update_or_create(
document=self.document,
user=self.user,
defaults={"role": role},
create_defaults={"role": role},
)
self.delete()
class Template(BaseModel):
"""HTML and CSS code used for formatting the print around the MarkDown body."""