✨(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:
committed by
Anthony LC
parent
8ccfdb3c6a
commit
239342fbbd
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user