From e2d6879716400cbd983885c5a4c50dd752f4e7ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Thu, 22 Jun 2017 20:10:17 +0200 Subject: [PATCH] use get_child() before serializing locations --- src/c3nav/mapdata/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c3nav/mapdata/api.py b/src/c3nav/mapdata/api.py index f8f2a1cd..9286bdbf 100644 --- a/src/c3nav/mapdata/api.py +++ b/src/c3nav/mapdata/api.py @@ -205,14 +205,14 @@ class LocationViewSet(RetrieveModelMixin, GenericViewSet): queryset = self.get_queryset(detailed=detailed, subconditions={'can_search': True}) if not search: - return Response([obj.serialize(include_type=True, detailed=detailed) for obj in queryset]) + return Response([obj.get_child().serialize(include_type=True, detailed=detailed) for obj in queryset]) words = search.lower().split(' ')[:10] results = queryset for word in words: results = [r for r in results if (word in r.title.lower() or (r.slug and word in r.slug.lower()))] # todo: rank results - return Response([obj.serialize(include_type=True, detailed='detailed' in request.GET) for obj in results]) + return Response([obj.get_child().serialize(include_type=True, detailed=detailed) for obj in results]) class SourceViewSet(MapdataViewSet):