Skip to content

Commit

Permalink
Merge pull request #210 from learningequality/settings
Browse files Browse the repository at this point in the history
Use Kolibri plugin built in settings and options augmentation.
  • Loading branch information
nucleogenesis authored Dec 20, 2024
2 parents 343157c + 73a75f3 commit ce98e7d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 62 deletions.
5 changes: 5 additions & 0 deletions kolibri_instant_schools_plugin/default_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
option_defaults = {
"Deployment": {
"LANGUAGES": ["en", "sw-tz", "fr-fr", "pt-br"],
}
}
46 changes: 6 additions & 40 deletions kolibri_instant_schools_plugin/dev_settings.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from kolibri_instant_schools_plugin.instant_schools_settings import * # noqa
from kolibri.deployment.default.settings.dev import * # noqa

# copied from kolibri.deployment.settings.dev
DEBUG = True

# Settings might be tuples, so switch to lists
INSTALLED_APPS = list(INSTALLED_APPS) + ["drf_yasg"] # noqa F405
webpack_middleware = "kolibri.core.webpack.middleware.WebpackErrorHandler"
no_login_popup_middleware = (
"kolibri.core.auth.middleware.XhrPreventLoginPromptMiddleware"
)
MIDDLEWARE = list(MIDDLEWARE) + [ # noqa F405
webpack_middleware,
no_login_popup_middleware,
]

INTERNAL_IPS = ["127.0.0.1"]

ROOT_URLCONF = "kolibri.deployment.default.dev_urls"

DEVELOPER_MODE = True
os.environ.update({"KOLIBRI_DEVELOPER_MODE": "True"})


REST_FRAMEWORK = {
"UNAUTHENTICATED_USER": "kolibri.core.auth.models.KolibriAnonymousUser",
"DEFAULT_AUTHENTICATION_CLASSES": [
# Always keep this first, so that we consistently return 403 responses
# when a request is unauthenticated.
"rest_framework.authentication.SessionAuthentication",
# Activate basic auth for external API testing tools
"rest_framework.authentication.BasicAuthentication",
],
"DEFAULT_RENDERER_CLASSES": (
"rest_framework.renderers.JSONRenderer",
"rest_framework.renderers.BrowsableAPIRenderer",
),
"EXCEPTION_HANDLER": "kolibri.core.utils.exception_handler.custom_exception_handler",
}

SWAGGER_SETTINGS = {"DEFAULT_INFO": "kolibri.deployment.default.dev_urls.api_info"}
USE_X_FORWARDED_HOST = False
USE_X_FORWARDED_PORT = False
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
ALLOW_CERTIFICATE_PUSHING = False
29 changes: 7 additions & 22 deletions kolibri_instant_schools_plugin/instant_schools_settings.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from kolibri.deployment.default.settings.base import *
INSTALLED_APPS = ["django.contrib.admin"]

INSTALLED_APPS = list(INSTALLED_APPS) + ["django.contrib.admin"]

OLD_DB_PATH = os.path.join(conf.KOLIBRI_HOME, 'db.sqlite3')
OLD_HASH_DB_PATH = os.path.join(conf.KOLIBRI_HOME, 'phonehashreverselookup.db')

DATABASES["default"]["NAME"] = os.path.join(conf.KOLIBRI_HOME, 'instant_schools_primary.sqlite3')

LANGUAGES = [
('en', 'English'),
('sw-tz', 'Kiswahili'),
('fr-fr', 'Français'),
('pt-br', 'Português'),
]

USE_X_FORWARDED_HOST = (not DEBUG)
USE_X_FORWARDED_PORT = (not DEBUG)
CSRF_COOKIE_SECURE = (not DEBUG)
SESSION_COOKIE_SECURE = (not DEBUG)
ALLOW_CERTIFICATE_PUSHING = (not DEBUG)
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = True
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
ALLOW_CERTIFICATE_PUSHING = True
SECURE_FRAME_DENY = False
X_FRAME_OPTIONS = "SAMEORIGIN"
X_FRAME_OPTIONS = "SAMEORIGIN"
2 changes: 2 additions & 0 deletions kolibri_instant_schools_plugin/kolibri_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class User(KolibriPluginBase):
root_view_urls = "root_urls"
translated_view_urls = "urls"
untranslated_view_urls = "untranslated_urls"
django_settings = "instant_schools_settings"
kolibri_option_defaults = "default_options"

@property
def url_slug(self):
Expand Down

0 comments on commit ce98e7d

Please sign in to comment.