Example #1
0
    def list(self, request):
        pk = request.QUERY_PARAMS.get('pk', None)
        ct = request.QUERY_PARAMS.get('ct', None)
        queryset = self.get_queryset(pk, ct)
        
        page = request.QUERY_PARAMS.get('page')
        paginator = Paginator(queryset, 48)
        try:
            actions = paginator.page(page)
        except PageNotAnInteger:
            actions = paginator.page(1)
        except EmptyPage:
            actions = paginator.page(paginator.num_pages)

        serializer = PaginatedActionSerializer(actions, context={'request': request})
        return Response(serializer.data)
Example #2
0
 def get(self, request):
     if request.user.is_anonymous(): return HttpResponseNotFound()
     if len(following(request.user)) > 0:
         actstream = user_stream(request.user)
     else:
         actstream = []
     page = request.QUERY_PARAMS.get('page')
     paginator = Paginator(actstream, settings.STREAM_PAGINATOR_LIMIT)
     try:
         actions = paginator.page(page)
     except PageNotAnInteger:
         actions = paginator.page(1)
     except EmptyPage:
         actions = paginator.page(paginator.num_pages)
     serializer = PaginatedActionSerializer(actions,
                                            context={'request': request})
     return Response(serializer.data)