Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade custom nav #8039

Merged
merged 3 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions kolibri/core/content/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ def _make_channel_endpoint_request(
# map the channel list into the format the Kolibri client-side expects
channels = list(map(self._studio_response_to_kolibri_response, resp.json()))

return Response(channels)
return channels

@staticmethod
def _get_lang_native_name(code):
Expand Down Expand Up @@ -1038,9 +1038,10 @@ def list(self, request, *args, **kwargs):
baseurl = request.GET.get("baseurl", None)
keyword = request.GET.get("keyword", None)
language = request.GET.get("language", None)
return self._make_channel_endpoint_request(
channels = self._make_channel_endpoint_request(
baseurl=baseurl, keyword=keyword, language=language
)
return Response(channels)

def retrieve(self, request, pk=None):
"""
Expand All @@ -1049,9 +1050,12 @@ def retrieve(self, request, pk=None):
baseurl = request.GET.get("baseurl", None)
keyword = request.GET.get("keyword", None)
language = request.GET.get("language", None)
return self._make_channel_endpoint_request(
channels = self._make_channel_endpoint_request(
identifier=pk, baseurl=baseurl, keyword=keyword, language=language
)
if not channels:
raise Http404
return Response(channels[0])

@list_route(methods=["get"])
def kolibri_studio_status(self, request, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/content/test/test_content_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ def test_channel_retrieve(self):
reverse("kolibri:core:remotechannel-detail", kwargs={"pk": "abc"}),
format="json",
)
self.assertEqual(response.data[0]["name"], "studio")
self.assertEqual(response.data["name"], "studio")

@mock_patch_decorator
def test_channel_info_cache(self):
Expand Down
3 changes: 1 addition & 2 deletions kolibri/core/content/utils/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,11 @@ def get_import_data_for_update(
i += batch_size
updated_ids_slice = updated_resource_ids[i : i + batch_size]

# Get all nodes that are marked as available but have missing supplementary files.
# Get all nodes that are marked as available but have missing files.
# This will ensure that we update thumbnails, and other files.
queried_file_objects.extend(
LocalFile.objects.filter(
available=False,
files__supplementary=True,
files__contentnode__in=ContentNode.objects.filter(
available=True, channel_id=channel_id
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import differenceBy from 'lodash/differenceBy';
import find from 'lodash/find';
import { getRemoteChannelByToken } from '../utils';
import { getRemoteChannelByToken, getRemoteChannelBundleByToken } from '../utils';

/**
* HACK: Makes a request to Kolibri Studio to get info on unlisted channels, then appends
Expand All @@ -18,7 +18,7 @@ export function getAllRemoteChannels(store, publicChannels) {
);
const promises = installedUnlistedChannels.map(installedChannel =>
getRemoteChannelByToken(installedChannel.id)
.then(([channel]) =>
.then(channel =>
Promise.resolve({
...channel,
...installedChannel,
Expand Down Expand Up @@ -47,7 +47,6 @@ export function getAllDriveChannels(store, drive) {
};
});
}

export function fetchUnlistedChannelInfo(store, channelId) {
jonboiser marked this conversation as resolved.
Show resolved Hide resolved
return getRemoteChannelByToken(channelId).then(channels => Array(channels));
return getRemoteChannelBundleByToken(channelId).then(channels => Array(channels));
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function getTransferredChannelOnPeerServer(store, { addressId, channelId
},
force: true,
})
.then(channels => {
resolve({ ...channels[0] });
.then(channel => {
resolve(channel);
})
.catch(() => {
// Only appears if channel with channelId is not on the device. Will still load
Expand Down
4 changes: 2 additions & 2 deletions kolibri/plugins/device/assets/src/modules/wizard/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ export function showSelectContentPage(store, params) {
// Force fetching because using cached version switches
// between returning an array and returning an object
.then(
channels => {
resolve({ ...channels[0] });
channel => {
resolve(channel);
},
error => {
if (error.response.status === 404) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getDeviceInfo } from '../../../modules/deviceInfo/handlers';
export function fetchPageData(channelId) {
const studioChannelPromise = RemoteChannelResource.fetchModel({ id: channelId, force: true })
.then(channel => {
this.studioChannel = { ...channel[0] };
this.studioChannel = channel;
})
.catch(() => {
// Fail silently in case server is offline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getChannelOnPeer(addressId, channelId) {
baseurl: location.base_url,
},
force: true,
}).then(([channel]) => {
}).then(channel => {
return {
...channel,
baseurl: location.base_url,
Expand All @@ -49,7 +49,7 @@ function getChannelOnStudio(channelId) {
return RemoteChannelResource.fetchModel({
id: channelId,
})
.then(([channel]) => {
.then(channel => {
return {
...channel,
baseurl: kolibriStudioUrl,
Expand Down