mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-20 08:38:01 +02:00
✨(backend) add a breadcrumb in the search response
In the search response, we want to display a breadcrumb for every document returned. For this we added a "parents" property containing a list documents, all are the parents of the current document (ordered by their depth). With this we can easily create a breadcrumb.
This commit is contained in:
@@ -167,6 +167,17 @@ class ListDocumentSerializer(serializers.ModelSerializer):
|
||||
return instance.ancestors_deleted_at
|
||||
|
||||
|
||||
class SearchDocumentSerializer(ListDocumentSerializer):
|
||||
"""Serialize items for search."""
|
||||
|
||||
parents = ListDocumentSerializer(many=True, read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = models.Document
|
||||
fields = ListDocumentSerializer.Meta.fields + ["parents"]
|
||||
read_only_fields = ListDocumentSerializer.Meta.read_only_fields + ["parents"]
|
||||
|
||||
|
||||
class DocumentLightSerializer(serializers.ModelSerializer):
|
||||
"""Minial document serializer for nesting in document accesses."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user