Skip to content
Snippets Groups Projects
Commit f0cb73b2 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Add parents to act search results

parent e007cd39
No related branches found
No related tags found
1 merge request!65Add paths to act search results
......@@ -56,9 +56,13 @@ def search_acts_post(data):
parents_ids=act_ids,
prefetch=('zone__image__server',)
)
all_parents = Element.objects.get_ascendings_paths(*act_ids)
for act in acts:
act.transcriptions = [transcriptions[tid] for tid in acts_tr_ids[act.id]]
act.surfaces = [surf.zone for surf in all_surfaces.get(act.id, [])]
act.parents = all_parents.get(act.id, [])
return sorted(acts, key=lambda a: act_scores[a.id], reverse=True)
......
......@@ -216,6 +216,12 @@ class ActSearchResultSerializer(serializers.ModelSerializer):
"""
transcriptions = TranscriptionSerializer(many=True)
surfaces = ZoneSerializer(many=True)
parents = serializers.ListField(
child=serializers.ListField(
child=ElementLightSerializer()
),
read_only=True,
)
viewer_url = ViewerURLField('api:act-manifest')
class Meta:
......@@ -226,6 +232,7 @@ class ActSearchResultSerializer(serializers.ModelSerializer):
'number',
'transcriptions',
'surfaces',
'parents',
'viewer_url',
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment