Skip to content

Commit

Permalink
Retain docstrings explaining pagination requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
markotibold committed Dec 21, 2012
1 parent 2860057 commit 86c9346
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 4 additions & 0 deletions fiber/rest_api/serializers.py
Expand Up @@ -48,5 +48,9 @@ class Meta:


class FiberPaginationSerializer(pagination.BasePaginationSerializer):
"""
Simple-data-grid expects a total_pages key for a paginated view.
Simple-data-grid expects rows as the key for objects.
"""
total_pages = serializers.Field(source='paginator.num_pages')
results_field = 'rows'
11 changes: 0 additions & 11 deletions fiber/rest_api/views.py
Expand Up @@ -143,18 +143,7 @@ def check_fields(self, order_by):
if order_by not in self.orderable_fields:
raise ErrorResponse(status=HTTP_400_BAD_REQUEST, content="Can not order by the passed value.")

def serialize_page_info(self, page):
"""
simple-data-grid expects a total_pages key for a paginated view.
"""
return {
'total_pages': page.paginator.num_pages,
}

def filter_response(self, obj):
"""
simple-data-grid expects rows instead of results (the Django REST framework default)
"""
obj = super(PaginatedListView, self).filter_response(obj)
if self.request.method.upper() == 'GET':
obj['rows'] = obj['results']
Expand Down

0 comments on commit 86c9346

Please sign in to comment.