API methods
- class kolibri.core.content.viewsets.channel_metadata.BaseChannelMetadataSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.channel_metadata.ChannelMetadataSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.channel_metadata.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.
- serializer_class
alias of
ChannelMetadataSerializer
- class kolibri.core.content.viewsets.channel_metadata.PublicChannelMetadataViewSet(*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.
- 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)
- class kolibri.core.content.viewsets.content_request.ContentDownloadRequestMetadataSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.content_request.ContentDownloadRequestSerializer(*args, **kwargs)[source]
- create(validated_data)[source]
We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:
return ExampleModel.objects.create(**validated_data)
If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:
example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance
The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.
- class kolibri.core.content.viewsets.content_request.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.viewsets.contentnode.base.AssessmentMetaDataSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.base.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!
- serializer_class
alias of
BaseContentNodeSerializer
- class kolibri.core.content.viewsets.contentnode.base.BaseContentNodeSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.base.ContentNodeFileSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.base.ContentNodeLanguageSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.base.ContentNodeSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.base.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.viewsets.contentnode.base.InternalContentNodeMixin[source]
A mixin for all content node viewsets for internal use, whereas BaseContentNodeMixin is reused for public API endpoints also.
- serializer_class
alias of
ContentNodeSerializer
- class kolibri.core.content.viewsets.contentnode.base.PublicContentNodeViewSet(*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.
- 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
PublicContentNodePagination
- class kolibri.core.content.viewsets.contentnode.bookmarks.BookmarkSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.bookmarks.ContentNodeBookmarkSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.bookmarks.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
- serializer_class
alias of
ContentNodeBookmarkSerializer
- class kolibri.core.content.viewsets.contentnode.granular.ContentNodeGranularSerializer(*args, **kwargs)[source]
- class kolibri.core.content.viewsets.contentnode.granular.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.viewsets.contentnode.progress.ContentNodeProgressViewset(**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
- serializer_class
alias of
Serializer
- class kolibri.core.content.viewsets.contentnode.tree.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.viewsets.contentnode.tree.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.viewsets.contentnode.tree.PublicContentNodeTreeViewSet(*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.
- 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)
- class kolibri.core.content.viewsets.contentnode.user.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
- class kolibri.core.content.viewsets.import_metadata.ImportMetadataViewset(**kwargs)[source]
-
- pagination_class
alias of
ImportMetadataPagination
- retrieve(request, pk=None)[source]
An endpoint to retrieve all content metadata required for importing a content node all of its ancestors, and any relevant needed metadata.
- Parameters:
request – request object
pk – id parent node
- Returns:
an object with keys for each content metadata table and a schema_version key
- class kolibri.core.content.viewsets.remote_channel.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.
- kolibri.core.content.views.get_by_channel_id_and_content_id(channel_id, content_id)[source]
Function to return a content node based on a channel_id and content_id