♻️(backend) refactor list view to allow filtering other views

the "filter_queryset" method is called in the middle of the
"get_object" method. We use the "get_object" in actions like
"children", "tree", etc. which start by calling "get_object"
but return lists of documents.

We would like to apply filters to these views but the it didn't
work because the "get_object" method was also impacted by the
filters...

In a future PR, we should take control of the "get_object" method
and decouple all this. We need a quick solution to allow releasing
the hierchical documents feature in the frontend.
This commit is contained in:
Samuel Paccoud - DINUM
2025-02-17 10:19:06 +01:00
committed by Manuel Raynaud
parent 0aabf26694
commit 56aa69f56a
7 changed files with 109 additions and 62 deletions

View File

@@ -177,10 +177,7 @@ class ListDocumentSerializer(serializers.ModelSerializer):
request = self.context.get("request")
if request:
paths_links_mapping = self.context.get("paths_links_mapping", None)
return document.get_abilities(
request.user, paths_links_mapping=paths_links_mapping
)
return document.get_abilities(request.user)
return {}