✨(backend) add new "descendants" action to document API endpoint
We want to be able to make a search query inside a hierchical document. It's elegant to do it as a document detail action so that we benefit from access control.
This commit is contained in:
committed by
Manuel Raynaud
parent
56aa69f56a
commit
2203d49a52
@@ -177,7 +177,14 @@ class ListDocumentSerializer(serializers.ModelSerializer):
|
||||
request = self.context.get("request")
|
||||
|
||||
if request:
|
||||
return document.get_abilities(request.user)
|
||||
paths_links_mapping = self.context.get("paths_links_mapping", None)
|
||||
# Retrieve ancestor links from paths_links_mapping (if provided)
|
||||
ancestors_links = (
|
||||
paths_links_mapping.get(document.path[: -document.steplen])
|
||||
if paths_links_mapping
|
||||
else None
|
||||
)
|
||||
return document.get_abilities(request.user, ancestors_links=ancestors_links)
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user