From 7751f7f68289637277b1a0f6d303a95f08b69aab Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Mon, 24 Apr 2017 21:57:22 +0200 Subject: [PATCH] Add ancestors, descendants and siblings API detail routes --- storage/apiviews.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/storage/apiviews.py b/storage/apiviews.py index 7738f5d..8ca834b 100644 --- a/storage/apiviews.py +++ b/storage/apiviews.py @@ -27,9 +27,20 @@ class ItemViewSet(viewsets.ModelViewSet): @detail_route() def children(self, request, pk): - """ - Returns a list of all the group names that the given - user belongs to. - """ item = self.get_object() return Response(self.serializer_class(item.get_children().all(), many=True).data) + + @detail_route() + def ancestors(self, request, pk): + item = self.get_object() + return Response(self.serializer_class(item.get_ancestors().all(), many=True).data) + + @detail_route() + def descendants(self, request, pk): + item = self.get_object() + return Response(self.serializer_class(item.get_descendants().all(), many=True).data) + + @detail_route() + def siblings(self, request, pk): + item = self.get_object() + return Response(self.serializer_class(item.get_siblings().all(), many=True).data)