Skip to content

Commit

Permalink
Merge pull request #9543 from jredrejo/015_for_kdp
Browse files Browse the repository at this point in the history
Changes in 0.15.x to use kolibri with external plugins
  • Loading branch information
rtibbles committed Jul 5, 2022
2 parents a7f84d1 + cf67b53 commit 953d32a
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
4 changes: 2 additions & 2 deletions kolibri/core/bookmarks/migrations/0001_initial.py
Expand Up @@ -15,7 +15,7 @@ class Migration(migrations.Migration):

dependencies = [
("kolibriauth", "0019_collection_no_mptt"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency("kolibriauth.FacilityUser"),
]

operations = [
Expand Down Expand Up @@ -57,7 +57,7 @@ class Migration(migrations.Migration):
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
],
Expand Down
13 changes: 12 additions & 1 deletion kolibri/core/device/migrations/0003_contentcachekey.py
Expand Up @@ -2,21 +2,32 @@
# Generated by Django 1.11.10 on 2018-09-05 17:20
from __future__ import unicode_literals

import sqlite3
import time

from django.db import migrations
from django.db import models
from django.db import transaction
from django.db.utils import OperationalError
from django.db.utils import ProgrammingError


def create_content_cache_key(apps, schema_editor):
from kolibri.core.device.models import ContentCacheKey

ContentCacheKey.update_cache_key()
try:
with transaction.atomic():
ContentCacheKey.update_cache_key()
except (OperationalError, ProgrammingError, sqlite3.OperationalError):
# let's not run this on a database cache
# that might not have been created yet
pass


class Migration(migrations.Migration):

dependencies = [("device", "0002_devicesettings_default_facility")]
atomic = False

operations = [
migrations.CreateModel(
Expand Down
4 changes: 2 additions & 2 deletions kolibri/core/device/migrations/0012_syncqueue.py
Expand Up @@ -15,7 +15,7 @@
class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency("kolibriauth.FacilityUser"),
("device", "0011_devicesettings_subset_of_users_device"),
]

Expand All @@ -36,7 +36,7 @@ class Migration(migrations.Migration):
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
],
Expand Down
4 changes: 2 additions & 2 deletions kolibri/core/device/migrations/0013_usersyncstatus.py
Expand Up @@ -12,7 +12,7 @@ class Migration(migrations.Migration):

dependencies = [
("morango", "0016_store_deserialization_error"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency("kolibriauth.FacilityUser"),
("device", "0012_syncqueue"),
]

Expand Down Expand Up @@ -43,7 +43,7 @@ class Migration(migrations.Migration):
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
],
Expand Down
4 changes: 2 additions & 2 deletions kolibri/core/exams/migrations/0005_individualsyncableexam.py
Expand Up @@ -15,7 +15,7 @@ class Migration(migrations.Migration):

dependencies = [
("kolibriauth", "0019_collection_no_mptt"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency("kolibriauth.FacilityUser"),
("exams", "0004_exam_add_dates_opened_created_and_archived"),
]

Expand Down Expand Up @@ -58,7 +58,7 @@ class Migration(migrations.Migration):
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
],
Expand Down
Expand Up @@ -22,7 +22,7 @@ class Migration(migrations.Migration):
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="exams",
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
migrations.AlterField(
Expand All @@ -32,7 +32,7 @@ class Migration(migrations.Migration):
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="assigned_exams",
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
]
Expand Up @@ -15,7 +15,7 @@ class Migration(migrations.Migration):

dependencies = [
("kolibriauth", "0019_collection_no_mptt"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency("kolibriauth.FacilityUser"),
("lessons", "0002_auto_20180221_1115"),
]

Expand Down Expand Up @@ -58,7 +58,7 @@ class Migration(migrations.Migration):
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
],
Expand Down
Expand Up @@ -22,7 +22,7 @@ class Migration(migrations.Migration):
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="lessons_created",
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
migrations.AlterField(
Expand All @@ -32,7 +32,7 @@ class Migration(migrations.Migration):
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="assigned_lessons",
to=settings.AUTH_USER_MODEL,
to="kolibriauth.FacilityUser",
),
),
]
26 changes: 14 additions & 12 deletions kolibri/utils/main.py
Expand Up @@ -25,6 +25,7 @@
from kolibri.core.upgrade import matches_version
from kolibri.core.upgrade import run_upgrades
from kolibri.core.utils.cache import process_cache
from kolibri.deployment.default.cache import CACHES
from kolibri.deployment.default.sqlite_db_names import ADDITIONAL_SQLITE_DATABASES
from kolibri.plugins.utils import autoremove_unavailable_plugins
from kolibri.plugins.utils import check_plugin_config_file_location
Expand Down Expand Up @@ -224,18 +225,19 @@ def _upgrades_before_django_setup(updated, version):


def _post_django_initialization():
if OPTIONS["Cache"]["CACHE_BACKEND"] != "redis":
try:
process_cache.cull()
except SQLite3DatabaseError:
shutil.rmtree(process_cache.directory, ignore_errors=True)
os.mkdir(process_cache.directory)
process_cache._cache = FanoutCache(
process_cache.directory,
settings.CACHES["process_cache"]["SHARDS"],
settings.CACHES["process_cache"]["TIMEOUT"],
**settings.CACHES["process_cache"]["OPTIONS"]
)
if "process_cache" in CACHES: # usually it means not using redis
if "DatabaseCache" not in CACHES["process_cache"]["BACKEND"]:
try:
process_cache.cull()
except SQLite3DatabaseError:
shutil.rmtree(process_cache.directory, ignore_errors=True)
os.mkdir(process_cache.directory)
process_cache._cache = FanoutCache(
process_cache.directory,
settings.CACHES["process_cache"]["SHARDS"],
settings.CACHES["process_cache"]["TIMEOUT"],
**settings.CACHES["process_cache"]["OPTIONS"]
)


def _upgrades_after_django_setup(updated, version):
Expand Down

0 comments on commit 953d32a

Please sign in to comment.