API methods
- class kolibri.core.content.api.BaseContentNodeMixin[source]
A base mixin for viewsets that need to return the same format of data serialization for ContentNodes. Also used for public ContentNode endpoints!
- class kolibri.core.content.api.BaseContentNodeTreeViewset(*args, **kwargs)[source]
- retrieve(request, pk=None)[source]
A nested, paginated representation of the children and grandchildren of a specific node
GET parameters on request can be: depth - a value of either 1 or 2 indicating the depth to recurse the tree, either 1 or 2 levels if this parameter is missing it will default to 2. next__gt - a value to return child nodes with a lft value greater than this, if missing defaults to None
The pagination object returned for “children” will have this form: results - a list of serialized children, that can also have their own nested children attribute. more - a dictionary or None, if a dictionary, will have an id key that is the id of the parent object for these children, and a params key that is a dictionary of the required query parameters to query more children for this parent - at a minimum this will include next__gt and depth, but may also include other query parameters for filtering content nodes.
The “more” property describes the “id” required to do URL reversal on this endpoint, and the params that should be passed as query parameters to get the next set of results for pagination.
- Parameters:
request – request object
pk – id parent node
- Returns:
an object representing the parent with a pagination object as “children”
- class kolibri.core.content.api.ChannelMetadataViewSet(*args, **kwargs)[source]
- dispatch(request, *args, **kwargs)
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- class kolibri.core.content.api.ContentNodeBookmarksViewset(*args, **kwargs)[source]
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class
alias of
ValuesViewsetLimitOffsetPagination
- class kolibri.core.content.api.ContentNodeGranularViewset(**kwargs)[source]
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class
alias of
ContentNodeGranularSerializer
- class kolibri.core.content.api.ContentNodeProgressViewset(*args, **kwargs)[source]
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class
alias of
OptionalPagination
- class kolibri.core.content.api.ContentNodeSearchViewset(*args, **kwargs)[source]
- initial(request, *args, **kwargs)
Runs anything that needs to occur prior to calling the method handler.
- class kolibri.core.content.api.ContentNodeTreeViewset(*args, **kwargs)[source]
- dispatch(request, *args, **kwargs)
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- retrieve(request, pk=None)[source]
A nested, paginated representation of the children and grandchildren of a specific node
GET parameters on request can be: depth - a value of either 1 or 2 indicating the depth to recurse the tree, either 1 or 2 levels if this parameter is missing it will default to 2. next__gt - a value to return child nodes with a lft value greater than this, if missing defaults to None
The pagination object returned for “children” will have this form: results - a list of serialized children, that can also have their own nested children attribute. more - a dictionary or None, if a dictionary, will have an id key that is the id of the parent object for these children, and a params key that is a dictionary of the required query parameters to query more children for this parent - at a minimum this will include next__gt and depth, but may also include other query parameters for filtering content nodes.
The “more” property describes the “id” required to do URL reversal on this endpoint, and the params that should be passed as query parameters to get the next set of results for pagination.
- Parameters:
request – request object
pk – id parent node
- Returns:
an object representing the parent with a pagination object as “children”
- class kolibri.core.content.api.ContentNodeViewset(*args, **kwargs)[source]
-
- dispatch(request, *args, **kwargs)
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- pagination_class
alias of
OptionalContentNodePagination
- class kolibri.core.content.api.ContentRequestViewset(*args, **kwargs)[source]
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class
alias of
OptionalPageNumberPagination
- serializer_class
alias of
ContentDownloadRequestSerializer
- class kolibri.core.content.api.FileViewset(**kwargs)[source]
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class
alias of
OptionalPageNumberPagination
- serializer_class
alias of
FileSerializer
- class kolibri.core.content.api.InternalContentNodeMixin[source]
A mixin for all content node viewsets for internal use, whereas BaseContentNodeMixin is reused for public API endpoints also.
- class kolibri.core.content.api.OptionalPageNumberPagination[source]
Pagination class that allows for page number-style pagination, when requested. To activate, the page_size argument must be set. For example, to request the first 20 records: ?page_size=20&page=1
- class kolibri.core.content.api.RemoteChannelViewSet(**kwargs)[source]
- dispatch(request, *args, **kwargs)
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- class kolibri.core.content.api.UserContentNodeViewset(*args, **kwargs)[source]
A content node viewset for filtering on user specific fields.
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- pagination_class
alias of
OptionalPagination