Ejemplo n.º 1
0
 def list(request):
     queryset = Body.objects.all()
     queryset = sort_by_field(queryset,
                              'followers',
                              reverse=True,
                              filt=Q(followers__active=True))
     serializer = BodySerializerMin(queryset, many=True)
     return Response(serializer.data)
Ejemplo n.º 2
0
 def get_children(obj):
     """Gets a min serialized children of a Body."""
     children = obj.children.prefetch_related('child')
     children = sort_by_field(children,
                              'child__followers',
                              reverse=True,
                              filt=Q(child__followers__active=True))
     return [BodySerializerMin(x.child).data for x in children.all()]
Ejemplo n.º 3
0
 def get_parents(obj):
     """Gets a min serialized parents of a Body."""
     parents = obj.parents.prefetch_related('parent')
     parents = sort_by_field(parents,
                             'parent__followers',
                             reverse=True,
                             filt=Q(parent__followers__active=True))
     return [BodySerializerMin(x.parent).data for x in parents.all()]
Ejemplo n.º 4
0
 def get_children(obj):
     """Gets a min serialized children of a Body."""
     children = sort_by_field(obj.children.all(),
                              'child__followers',
                              reverse=True)
     return [BodySerializerMin(x.child).data for x in children]
Ejemplo n.º 5
0
 def get_parents(obj):
     """Gets a min serialized parents of a Body."""
     parents = sort_by_field(obj.parents.all(),
                             'parent__followers',
                             reverse=True)
     return [BodySerializerMin(x.parent).data for x in parents]
Ejemplo n.º 6
0
 def list(cls, request):  #pylint: disable=unused-argument
     queryset = Body.objects.all()
     queryset = sort_by_field(queryset, 'followers', reverse=True)
     serializer = BodySerializerMin(queryset, many=True)
     return Response(serializer.data)