(backend) add API endpoint action to restore a soft deleted document

Only owners can see and restore deleted documents. They can only do
it during the grace period before the document is considered hard
deleted and hidden from everybody on the API.
This commit is contained in:
Samuel Paccoud - DINUM
2025-01-05 14:43:15 +01:00
committed by Anthony LC
parent 8ccfdb3c6a
commit 239342fbbd
6 changed files with 203 additions and 1 deletions

View File

@@ -714,6 +714,22 @@ class DocumentViewSet(
{"message": "Document moved successfully."}, status=status.HTTP_200_OK
)
@drf.decorators.action(
detail=True,
methods=["post"],
)
def restore(self, request, *args, **kwargs):
"""
Restore a soft-deleted document if it was deleted less than x days ago.
"""
document = self.get_object()
document.restore()
return drf_response.Response(
{"detail": "Document has been successfully restored."},
status=status.HTTP_200_OK,
)
@drf.decorators.action(
detail=True,
methods=["get", "post"],