Merge pull request #17093 from edx/arch/django-app-plugin
Django App Plugins
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
This is the default template for our main set of AWS servers. This does NOT
|
||||
cover the content machines, which use content.py
|
||||
This is the default template for our main set of AWS servers.
|
||||
|
||||
Common traits:
|
||||
* Use memcached, and cache-backed sessions
|
||||
@@ -46,7 +45,6 @@ CONFIG_ROOT = path(os.environ.get('CONFIG_ROOT', ENV_ROOT))
|
||||
# prefix.
|
||||
CONFIG_PREFIX = SERVICE_VARIANT + "." if SERVICE_VARIANT else ""
|
||||
|
||||
|
||||
################################ ALWAYS THE SAME ##############################
|
||||
|
||||
DEBUG = False
|
||||
@@ -271,12 +269,6 @@ BULK_EMAIL_ROUTING_KEY = ENV_TOKENS.get('BULK_EMAIL_ROUTING_KEY', HIGH_PRIORITY_
|
||||
# we have to reset the value here.
|
||||
BULK_EMAIL_ROUTING_KEY_SMALL_JOBS = ENV_TOKENS.get('BULK_EMAIL_ROUTING_KEY_SMALL_JOBS', LOW_PRIORITY_QUEUE)
|
||||
|
||||
# Queue to use for updating persistent grades
|
||||
RECALCULATE_GRADES_ROUTING_KEY = ENV_TOKENS.get('RECALCULATE_GRADES_ROUTING_KEY', LOW_PRIORITY_QUEUE)
|
||||
|
||||
# Queue to use for updating grades due to grading policy change
|
||||
POLICY_CHANGE_GRADES_ROUTING_KEY = ENV_TOKENS.get('POLICY_CHANGE_GRADES_ROUTING_KEY', LOW_PRIORITY_QUEUE)
|
||||
|
||||
# Queue to use for expiring old entitlements
|
||||
ENTITLEMENTS_EXPIRATION_ROUTING_KEY = ENV_TOKENS.get('ENTITLEMENTS_EXPIRATION_ROUTING_KEY', LOW_PRIORITY_QUEUE)
|
||||
|
||||
@@ -1077,15 +1069,6 @@ PARENTAL_CONSENT_AGE_LIMIT = ENV_TOKENS.get(
|
||||
PARENTAL_CONSENT_AGE_LIMIT
|
||||
)
|
||||
|
||||
############## Settings for ACE ####################################
|
||||
ACE_ENABLED_CHANNELS = ENV_TOKENS.get('ACE_ENABLED_CHANNELS', ACE_ENABLED_CHANNELS)
|
||||
ACE_ENABLED_POLICIES = ENV_TOKENS.get('ACE_ENABLED_POLICIES', ACE_ENABLED_POLICIES)
|
||||
ACE_CHANNEL_SAILTHRU_DEBUG = ENV_TOKENS.get('ACE_CHANNEL_SAILTHRU_DEBUG', ACE_CHANNEL_SAILTHRU_DEBUG)
|
||||
ACE_CHANNEL_SAILTHRU_TEMPLATE_NAME = ENV_TOKENS.get('ACE_CHANNEL_SAILTHRU_TEMPLATE_NAME', ACE_CHANNEL_SAILTHRU_TEMPLATE_NAME)
|
||||
ACE_CHANNEL_SAILTHRU_API_KEY = AUTH_TOKENS.get('ACE_CHANNEL_SAILTHRU_API_KEY', ACE_CHANNEL_SAILTHRU_API_KEY)
|
||||
ACE_CHANNEL_SAILTHRU_API_SECRET = AUTH_TOKENS.get('ACE_CHANNEL_SAILTHRU_API_SECRET', ACE_CHANNEL_SAILTHRU_API_SECRET)
|
||||
ACE_ROUTING_KEY = ENV_TOKENS.get('ACE_ROUTING_KEY', ACE_ROUTING_KEY)
|
||||
|
||||
# Do NOT calculate this dynamically at startup with git because it's *slow*.
|
||||
EDX_PLATFORM_REVISION = ENV_TOKENS.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REVISION)
|
||||
|
||||
@@ -1103,6 +1086,11 @@ COMPLETION_VIDEO_COMPLETE_PERCENTAGE = ENV_TOKENS.get(
|
||||
COMPLETION_VIDEO_COMPLETE_PERCENTAGE,
|
||||
)
|
||||
|
||||
############################### Plugin Settings ###############################
|
||||
|
||||
from openedx.core.djangolib.django_plugins import DjangoAppRegistry, ProjectType, SettingsType
|
||||
DjangoAppRegistry.add_plugin_settings(__name__, ProjectType.LMS, SettingsType.AWS)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
@@ -2015,14 +2015,6 @@ BULK_EMAIL_LOG_SENT_EMAILS = False
|
||||
# parallel, and what the SES rate is.
|
||||
BULK_EMAIL_RETRY_DELAY_BETWEEN_SENDS = 0.02
|
||||
|
||||
############################# Persistent Grades ####################################
|
||||
|
||||
# Queue to use for updating persistent grades
|
||||
RECALCULATE_GRADES_ROUTING_KEY = LOW_PRIORITY_QUEUE
|
||||
|
||||
# Queue to use for updating grades due to grading policy change
|
||||
POLICY_CHANGE_GRADES_ROUTING_KEY = LOW_PRIORITY_QUEUE
|
||||
|
||||
############################# Email Opt In ####################################
|
||||
|
||||
# Minimum age for organization-wide email opt in
|
||||
@@ -2105,9 +2097,6 @@ INSTALLED_APPS = [
|
||||
# For content serving
|
||||
'openedx.core.djangoapps.contentserver',
|
||||
|
||||
# Theming
|
||||
'openedx.core.djangoapps.theming.apps.ThemingConfig',
|
||||
|
||||
# Site configuration for theming and behavioral modification
|
||||
'openedx.core.djangoapps.site_configuration',
|
||||
|
||||
@@ -2136,7 +2125,6 @@ INSTALLED_APPS = [
|
||||
'openedx.core.djangoapps.course_groups',
|
||||
'bulk_email',
|
||||
'branding',
|
||||
'lms.djangoapps.grades.apps.GradesConfig',
|
||||
|
||||
# Signals
|
||||
'openedx.core.djangoapps.signals.apps.SignalConfig',
|
||||
@@ -2344,8 +2332,6 @@ INSTALLED_APPS = [
|
||||
'database_fixups',
|
||||
|
||||
'openedx.core.djangoapps.waffle_utils',
|
||||
'openedx.core.djangoapps.ace_common.apps.AceCommonConfig',
|
||||
'openedx.core.djangoapps.schedules.apps.SchedulesConfig',
|
||||
|
||||
# Course Goals
|
||||
'lms.djangoapps.course_goals',
|
||||
@@ -3443,20 +3429,6 @@ COURSES_API_CACHE_TIMEOUT = 3600 # Value is in seconds
|
||||
COURSEGRAPH_JOB_QUEUE = LOW_PRIORITY_QUEUE
|
||||
|
||||
|
||||
############## Settings for ACE ####################################
|
||||
ACE_ENABLED_CHANNELS = [
|
||||
'file_email'
|
||||
]
|
||||
ACE_ENABLED_POLICIES = [
|
||||
'bulk_email_optout'
|
||||
]
|
||||
ACE_CHANNEL_SAILTHRU_DEBUG = True
|
||||
ACE_CHANNEL_SAILTHRU_TEMPLATE_NAME = 'Automated Communication Engine Email'
|
||||
ACE_CHANNEL_SAILTHRU_API_KEY = None
|
||||
ACE_CHANNEL_SAILTHRU_API_SECRET = None
|
||||
|
||||
ACE_ROUTING_KEY = LOW_PRIORITY_QUEUE
|
||||
|
||||
# Initialize to 'unknown', but read from JSON in aws.py
|
||||
EDX_PLATFORM_REVISION = 'unknown'
|
||||
|
||||
@@ -3469,3 +3441,9 @@ COMPLETION_VIDEO_COMPLETE_PERCENTAGE = 0.95
|
||||
############### Settings for Django Rate limit #####################
|
||||
RATELIMIT_ENABLE = True
|
||||
RATELIMIT_RATE = '30/m'
|
||||
|
||||
############## Plugin Django Apps #########################
|
||||
|
||||
from openedx.core.djangolib.django_plugins import DjangoAppRegistry, ProjectType, SettingsType
|
||||
INSTALLED_APPS.extend(DjangoAppRegistry.get_plugin_apps(ProjectType.LMS))
|
||||
DjangoAppRegistry.add_plugin_settings(__name__, ProjectType.LMS, SettingsType.COMMON)
|
||||
|
||||
@@ -269,21 +269,9 @@ JWT_AUTH.update({
|
||||
'JWT_AUDIENCE': 'lms-key',
|
||||
})
|
||||
|
||||
|
||||
############## Settings for ACE ####################################
|
||||
ACE_ENABLED_CHANNELS = [
|
||||
'file_email'
|
||||
]
|
||||
ACE_ENABLED_POLICIES = [
|
||||
'bulk_email_optout'
|
||||
]
|
||||
ACE_CHANNEL_SAILTHRU_DEBUG = True
|
||||
ACE_CHANNEL_SAILTHRU_TEMPLATE_NAME = 'Automated Communication Engine Email'
|
||||
ACE_CHANNEL_SAILTHRU_API_KEY = None
|
||||
ACE_CHANNEL_SAILTHRU_API_SECRET = None
|
||||
|
||||
ACE_ROUTING_KEY = LOW_PRIORITY_QUEUE
|
||||
|
||||
#####################################################################
|
||||
from openedx.core.djangolib.django_plugins import DjangoAppRegistry, ProjectType, SettingsType
|
||||
DjangoAppRegistry.add_plugin_settings(__name__, ProjectType.LMS, SettingsType.DEVSTACK)
|
||||
|
||||
#####################################################################
|
||||
# See if the developer has any local overrides.
|
||||
|
||||
101
lms/envs/docs/README.rst
Normal file
101
lms/envs/docs/README.rst
Normal file
@@ -0,0 +1,101 @@
|
||||
LMS Configuration Settings
|
||||
==========================
|
||||
|
||||
The lms.envs module contains project-wide settings, defined in python modules
|
||||
using the standard `Django Settings`_ mechanism.
|
||||
|
||||
.. _Django Settings: https://docs.djangoproject.com/en/1.11/topics/settings/
|
||||
|
||||
Different python modules are used for different setting configuration options.
|
||||
To prevent duplication of settings, modules import values from other modules,
|
||||
as shown in the diagram below.
|
||||
|
||||
.. image:: images/lms_settings.png
|
||||
|
||||
|
||||
JSON Configuration Files
|
||||
------------------------
|
||||
|
||||
In addition, there is a mechanism for reading and overriding configuration
|
||||
settings from JSON files on-disk. The :file:`/lms/envs/aws.py` module loads
|
||||
settings from ``lms.env.json`` and ``lms.auth.json`` files. All
|
||||
security-sensitive settings and data belong in the ``lms.auth.json`` file, while
|
||||
the rest are configured via the ``lms.env.json`` file.
|
||||
|
||||
These JSON files allow open edX operators to configure the django runtime
|
||||
without needing to make any changes to source-controlled python files in
|
||||
edx-platform. Therefore, they are not checked into the edx-platform repo.
|
||||
Rather, they are generated from the `edxapp playbook in the configuration
|
||||
repo`_ and available in the ``/edx/app/edxapp/`` folder on edX servers.
|
||||
|
||||
.. _edxapp playbook in the configuration repo: https://github.com/edx/configuration/tree/master/playbooks/roles/edxapp
|
||||
|
||||
|
||||
Feature Flags and Settings Guidelines
|
||||
-------------------------------------
|
||||
|
||||
For guidelines on using Django settings and feature flag mechanisms in the edX
|
||||
platform, please see `Feature Flags and Settings`_.
|
||||
|
||||
.. _Feature Flags and Settings: https://openedx.atlassian.net/wiki/spaces/OpenDev/pages/40862688/Feature+Flags+and+Settings+on+edx-platform
|
||||
|
||||
|
||||
Derived Settings
|
||||
----------------
|
||||
In cases where you need to define one or more settings relative to the value of
|
||||
another setting, you can explicitly designate them as derived calculations.
|
||||
This can let you override one setting (such as a path or a feature toggle) and
|
||||
have it automatically propagate to other settings which are defined in terms of
|
||||
that value, without needing to track down all potentially impacted settings and
|
||||
explicitly override them as well. This can be useful for test setting overrides
|
||||
even if you don't anticipate end users customizing the value very often.
|
||||
|
||||
For example::
|
||||
|
||||
def _make_locale_paths(settings):
|
||||
locale_paths = [settings.REPO_ROOT + '/conf/locale'] # edx-platform/conf/locale/
|
||||
if settings.ENABLE_COMPREHENSIVE_THEMING:
|
||||
# Add locale paths to settings for comprehensive theming.
|
||||
for locale_path in settings.COMPREHENSIVE_THEME_LOCALE_PATHS:
|
||||
locale_paths += (path(locale_path), )
|
||||
return locale_paths
|
||||
LOCALE_PATHS = _make_locale_paths
|
||||
derived('LOCALE_PATHS')
|
||||
|
||||
In this case, ``LOCALE_PATHS`` will be defined correctly at the end of the
|
||||
settings module parsing no matter what ``REPO_ROOT``,
|
||||
`ENABLE_COMPREHENSIVE_THEMING`, and ``COMPREHENSIVE_THEME_LOCALE_PATHS`` are
|
||||
currently set to. This is true even if the ``LOCALE_PATHS`` calculation was
|
||||
defined in ``lms/envs/common.py`` and you're using ``lms/envs/aws.py`` which
|
||||
includes overrides both from that module and the JSON configuration files.
|
||||
|
||||
List entries and dictionary values can also be derived from other settings, even
|
||||
when nested within each other::
|
||||
|
||||
def _make_mako_template_dirs(settings):
|
||||
"""
|
||||
Derives the final Mako template directories list from other settings.
|
||||
"""
|
||||
if settings.ENABLE_COMPREHENSIVE_THEMING:
|
||||
themes_dirs = get_theme_base_dirs_from_settings(settings.COMPREHENSIVE_THEME_DIRS)
|
||||
for theme in get_themes_unchecked(themes_dirs, settings.PROJECT_ROOT):
|
||||
if theme.themes_base_dir not in settings.MAKO_TEMPLATE_DIRS_BASE:
|
||||
settings.MAKO_TEMPLATE_DIRS_BASE.insert(0, theme.themes_base_dir)
|
||||
if settings.FEATURES.get('USE_MICROSITES', False) and getattr(settings, "MICROSITE_CONFIGURATION", False):
|
||||
settings.MAKO_TEMPLATE_DIRS_BASE.insert(0, settings.MICROSITE_ROOT_DIR)
|
||||
return settings.MAKO_TEMPLATE_DIRS_BASE
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'NAME': 'django',
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
...
|
||||
},
|
||||
{
|
||||
'NAME': 'mako',
|
||||
'BACKEND': 'edxmako.backend.Mako',
|
||||
'APP_DIRS': False,
|
||||
'DIRS': _make_mako_template_dirs,
|
||||
},
|
||||
]
|
||||
derived_collection_entry('TEMPLATES', 1, 'DIRS')
|
||||
BIN
lms/envs/docs/images/lms_settings.png
Normal file
BIN
lms/envs/docs/images/lms_settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 167 KiB |
@@ -297,10 +297,6 @@ OIDC_COURSE_HANDLER_CACHE_TIMEOUT = 0
|
||||
FEATURES['ENABLE_MOBILE_REST_API'] = True
|
||||
FEATURES['ENABLE_VIDEO_ABSTRACTION_LAYER_API'] = True
|
||||
|
||||
########################### Grades #################################
|
||||
FEATURES['PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'] = True
|
||||
FEATURES['ASSUME_ZERO_GRADE_IF_ABSENT_FOR_ALL_TESTS'] = True
|
||||
|
||||
###################### Payment ##############################3
|
||||
# Enable fake payment processing page
|
||||
FEATURES['ENABLE_PAYMENT_FAKE'] = True
|
||||
@@ -532,9 +528,6 @@ NOTES_DISABLED_TABS = []
|
||||
# Enable EdxNotes for tests.
|
||||
FEATURES['ENABLE_EDXNOTES'] = True
|
||||
|
||||
# Enable teams feature for tests.
|
||||
FEATURES['ENABLE_TEAMS'] = True
|
||||
|
||||
# Enable courseware search for tests
|
||||
FEATURES['ENABLE_COURSEWARE_SEARCH'] = True
|
||||
|
||||
@@ -601,6 +594,11 @@ ACTIVATION_EMAIL_FROM_ADDRESS = 'test_activate@edx.org'
|
||||
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||
|
||||
####################### Plugin Settings ##########################
|
||||
|
||||
from openedx.core.djangolib.django_plugins import DjangoAppRegistry, ProjectType, SettingsType
|
||||
DjangoAppRegistry.add_plugin_settings(__name__, ProjectType.LMS, SettingsType.TEST)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
Reference in New Issue
Block a user