✨(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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user