Files
edx-platform/lms/djangoapps/ccx/api/v0/paginators.py
Giovanni Di Milia e63194c1cd Added CCX REST APIs
CCX REST APIs
OAUTH2 authorization for CCX APIs
- oauth2 authorization required for ccx list.
- Course-instructor permission for ccx api endpoint
- Protection for detail view too.

Tests for CCX REST APIs and OAUTH2 authorization
2016-01-27 11:04:28 -05:00

27 lines
863 B
Python

""" CCX API v0 Paginators. """
from openedx.core.lib.api.paginators import DefaultPagination
class CCXAPIPagination(DefaultPagination):
"""
Pagination format used by the CCX API.
"""
page_size_query_param = "page_size"
def get_paginated_response(self, data):
"""
Annotate the response with pagination information.
"""
response = super(CCXAPIPagination, self).get_paginated_response(data)
# Add the current page to the response.
response.data["current_page"] = self.page.number
# This field can be derived from other fields in the response,
# so it may make sense to have the JavaScript client calculate it
# instead of including it in the response.
response.data["start"] = (self.page.number - 1) * self.get_page_size(self.request)
return response