Skip to content

Commit a433643

Browse files
committed
Merge branch 'release-v0.5.x' into develop
# Conflicts: # kolibri/plugins/document_pdf_render/assets/src/views/index.vue # kolibri/plugins/learn/assets/src/views/content-page/index.vue # kolibri/plugins/learn/assets/src/views/learn-page/index.vue # kolibri/plugins/learn/assets/src/views/points-popup/index.vue # yarn.lock
2 parents 0cc905d + e1b72fc commit a433643

File tree

41 files changed

+6234
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6234
-152
lines changed

frontend_build/src/parse_bundle_plugin.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ var parseBundlePlugin = function(data, base_dir) {
9292
],
9393
};
9494

95+
// Calculate these paths here, so that we can export __publicPath as a variable in the webpack define plugin
96+
var publicPath, outputPath;
97+
98+
if (process.env.DEV_SERVER) {
99+
var devServerConfig = require('./webpackdevserverconfig');
100+
// If running webpack dev server point to that endpoint.
101+
publicPath = devServerConfig.publicPath;
102+
// Set output path to base dir, as no files will be written - all built files are cached in memory.
103+
outputPath = devServerConfig.basePath
104+
? path.resolve(path.join(base_dir, devServerConfig.basePath))
105+
: path.resolve(base_dir);
106+
} else {
107+
publicPath = path.join('/', data.static_url_root, data.name, '/');
108+
outputPath = path.join(data.static_dir, data.name);
109+
}
110+
95111
bundle.plugins = bundle.plugins.concat([
96112
new ExtractTextPlugin('[name]' + data.version + '.css'),
97113
new WebpackRTLPlugin(),
@@ -110,27 +126,14 @@ var parseBundlePlugin = function(data, base_dir) {
110126
__events: JSON.stringify(data.events || {}),
111127
__once: JSON.stringify(data.once || {}),
112128
__version: JSON.stringify(data.version),
129+
// This is necessary to allow modules that use service workers to fetch their service worker code
130+
__publicPath: JSON.stringify(publicPath),
113131
}),
114132
new extract$trs(data.locale_data_folder, data.name),
115133
]);
116134

117135
bundle = merge.smart(bundle, local_config);
118136

119-
var publicPath, outputPath;
120-
121-
if (process.env.DEV_SERVER) {
122-
var devServerConfig = require('./webpackdevserverconfig');
123-
// If running webpack dev server point to that endpoint.
124-
publicPath = devServerConfig.publicPath;
125-
// Set output path to base dir, as no files will be written - all built files are cached in memory.
126-
outputPath = devServerConfig.basePath
127-
? path.resolve(path.join(base_dir, devServerConfig.basePath))
128-
: path.resolve(base_dir);
129-
} else {
130-
publicPath = path.join('/', data.static_url_root, data.name, '/');
131-
outputPath = path.join(data.static_dir, data.name);
132-
}
133-
134137
bundle.core_name = data.core_name;
135138
bundle.name = data.name;
136139
bundle.context = base_dir;

kolibri/content/api.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.db.models import Q, Sum
88
from django.db.models.aggregates import Count
99
from kolibri.content import models, serializers
10-
from kolibri.content.content_db_router import get_active_content_database
10+
from kolibri.content.content_db_router import get_active_content_database, using_content_database
1111
from kolibri.logger.models import ContentSessionLog, ContentSummaryLog
1212
from le_utils.constants import content_kinds
1313
from rest_framework import filters, pagination, viewsets
@@ -359,10 +359,11 @@ def get_queryset(self):
359359

360360
class ChannelFileSummaryViewSet(viewsets.ViewSet):
361361
def list(self, request, **kwargs):
362-
file_summary = models.File.objects.aggregate(
363-
total_files=Count('pk'),
364-
total_file_size=Sum('file_size')
365-
)
366-
file_summary['channel_id'] = get_active_content_database()
367-
# Need to wrap in an array to be fetchable as a Collection on client
368-
return Response([file_summary])
362+
with using_content_database(kwargs['channel_id']):
363+
file_summary = models.File.objects.aggregate(
364+
total_files=Count('pk'),
365+
total_file_size=Sum('file_size')
366+
)
367+
file_summary['channel_id'] = get_active_content_database()
368+
# Need to wrap in an array to be fetchable as a Collection on client
369+
return Response([file_summary])

kolibri/content/middleware.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ class ContentDBRoutingMiddleware(object):
99
"""
1010

1111
def process_view(self, request, view_func, view_args, view_kwargs):
12-
request.PREVIOUSLY_ACTIVE_CONTENT_DATABASE = get_active_content_database(return_none_if_not_set=True)
13-
if "channel_id" in view_kwargs:
14-
set_active_content_database(view_kwargs["channel_id"])
12+
if view_func.__name__ == 'TasksViewSet':
13+
pass # Fix #1818.1: skip get_active_content_database for Task workers to avoid locking DB
14+
else:
15+
request.PREVIOUSLY_ACTIVE_CONTENT_DATABASE = get_active_content_database(return_none_if_not_set=True)
16+
if "channel_id" in view_kwargs:
17+
set_active_content_database(view_kwargs["channel_id"])
1518

1619
def process_response(self, request, response):
1720
set_active_content_database(getattr(request, "PREVIOUSLY_ACTIVE_CONTENT_DATABASE", None))

kolibri/content/utils/annotation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ def update_channel_metadata_cache():
3232
if ch_metadata_obj.last_updated is None:
3333
ch_metadata_obj.last_updated = local_now()
3434
ch_metadata_obj.save()
35+
36+
# Fix #1818.1 content database files get locked (this is called on startup)
37+
from django.db import connections
38+
connections.close_all()

kolibri/content/utils/channels.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ def enumerate_content_database_file_paths(content_database_dir):
5353
def read_channel_metadata_from_db_file(channeldbpath):
5454
# import here to avoid circular imports whenever kolibri.content.models imports utils too
5555
from kolibri.content.models import ChannelMetadata
56-
5756
with using_content_database(channeldbpath):
58-
return ChannelMetadata.objects.first()
57+
channel_metadata = ChannelMetadata.objects.first()
58+
59+
# FIX for #1818.2: DB file on removable media remains locked after import
60+
from django.db import connections
61+
connections.close_all()
62+
63+
return channel_metadata
64+
5965

6066
def get_channels_for_data_folder(datafolder):
6167
channels = []

kolibri/core/assets/src/mixins/responsive-window.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function addWindowListener(cb) {
160160
}
161161

162162
function removeWindowListener(cb) {
163-
windowListeners.pop(cb);
163+
windowListeners.splice(windowListeners.indexOf(cb), 1);
164164
}
165165

166166
/* setup */

kolibri/core/assets/src/state/getters.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function contentPoints(state) {
7373
return Math.floor(state.core.logging.summary.progress) * MaxPointsPerContent;
7474
}
7575

76+
function sessionTimeSpent(state) {
77+
return state.core.logging.session.time_spent;
78+
}
79+
7680
export {
7781
isUserLoggedIn,
7882
isSuperuser,
@@ -88,4 +92,5 @@ export {
8892
contentPoints,
8993
currentUserId,
9094
facilityConfig,
95+
sessionTimeSpent,
9196
};

kolibri/core/assets/src/views/k-breadcrumbs/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22

3-
<div>
3+
<div v-show="crumbs.length > 1">
44
<nav class="breadcrumbs">
55
<div v-show="collapsedCrumbs.length" class="breadcrumbs-dropdown-wrapper">
66
<ui-icon-button :has-dropdown="true" icon="expand_more" size="small">

kolibri/core/templates/kolibri/base.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<link rel="shortcut icon" href="{% static 'images/logo.ico' %}">
1111
<title>{% trans "Kolibri" %}</title>
12+
{% if LANGUAGE_CODE == "ach-ug" %}
13+
<script type="text/javascript">
14+
var _jipt = [];
15+
_jipt.push(['project', 'kolibri']);
16+
</script>
17+
<script type="text/javascript" src="//cdn.crowdin.com/jipt/jipt.js"></script>
18+
{% endif %}
1219
</head>
1320
<body>
1421
<rootvue>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, print_function, unicode_literals
3+
4+
import django.conf.locale
5+
6+
from .base import * # noqa isort:skip @UnusedWildImport
7+
8+
LANGUAGES = [ # noqa
9+
('ach-ug', 'In context translation'),
10+
]
11+
12+
EXTRA_LANG_INFO = {
13+
'ach-ug': {
14+
'bidi': False,
15+
'code': 'ach-ug',
16+
'name': 'In context translation',
17+
'name_local': 'Language Name',
18+
},
19+
}
20+
21+
LANGUAGE_CODE = "ach-ug"
22+
23+
django.conf.locale.LANG_INFO.update(EXTRA_LANG_INFO)

0 commit comments

Comments
 (0)