Add ancestors, descendants and siblings API detail routes
This commit is contained in:
parent
95b6ac712b
commit
7751f7f682
|
@ -27,9 +27,20 @@ class ItemViewSet(viewsets.ModelViewSet):
|
||||||
|
|
||||||
@detail_route()
|
@detail_route()
|
||||||
def children(self, request, pk):
|
def children(self, request, pk):
|
||||||
"""
|
|
||||||
Returns a list of all the group names that the given
|
|
||||||
user belongs to.
|
|
||||||
"""
|
|
||||||
item = self.get_object()
|
item = self.get_object()
|
||||||
return Response(self.serializer_class(item.get_children().all(), many=True).data)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue