Skip to content

Commit a98dd3f

Browse files
Taylor Paynekdmccormick
authored andcommitted
refactor: move explicitly shared settings into new common module
1 parent ef6dbd9 commit a98dd3f

12 files changed

Lines changed: 824 additions & 814 deletions

File tree

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ omit =
2525
common/djangoapps/*/migrations/*
2626
openedx/core/djangoapps/*/migrations/*
2727
openedx/core/djangoapps/debug/*
28+
openedx/envs/*
2829
openedx/features/*/migrations/*
2930

3031
concurrency=multiprocessing

.coveragerc-local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ omit =
2424
common/djangoapps/*/migrations/*
2525
openedx/core/djangoapps/*/migrations/*
2626
openedx/core/djangoapps/debug/*
27+
openedx/envs/*
2728
openedx/features/*/migrations/*
2829

2930
concurrency=multiprocessing

.github/workflows/pylint-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- module-name: openedx-1
2121
path: "openedx/core/types/ openedx/core/djangoapps/ace_common/ openedx/core/djangoapps/agreements/ openedx/core/djangoapps/api_admin/ openedx/core/djangoapps/auth_exchange/ openedx/core/djangoapps/bookmarks/ openedx/core/djangoapps/cache_toolbox/ openedx/core/djangoapps/catalog/ openedx/core/djangoapps/ccxcon/ openedx/core/djangoapps/commerce/ openedx/core/djangoapps/common_initialization/ openedx/core/djangoapps/common_views/ openedx/core/djangoapps/config_model_utils/ openedx/core/djangoapps/content/ openedx/core/djangoapps/content_libraries/ openedx/core/djangoapps/content_staging/ openedx/core/djangoapps/contentserver/ openedx/core/djangoapps/cookie_metadata/ openedx/core/djangoapps/cors_csrf/ openedx/core/djangoapps/course_apps/ openedx/core/djangoapps/course_date_signals/ openedx/core/djangoapps/course_groups/ openedx/core/djangoapps/courseware_api/ openedx/core/djangoapps/crawlers/ openedx/core/djangoapps/credentials/ openedx/core/djangoapps/credit/ openedx/core/djangoapps/dark_lang/ openedx/core/djangoapps/debug/ openedx/core/djangoapps/discussions/ openedx/core/djangoapps/django_comment_common/ openedx/core/djangoapps/embargo/ openedx/core/djangoapps/enrollments/ openedx/core/djangoapps/external_user_ids/ openedx/core/djangoapps/zendesk_proxy/ openedx/core/djangolib/ openedx/core/lib/ openedx/core/djangoapps/course_live/"
2222
- module-name: openedx-2
23-
path: "openedx/core/djangoapps/geoinfo/ openedx/core/djangoapps/header_control/ openedx/core/djangoapps/heartbeat/ openedx/core/djangoapps/lang_pref/ openedx/core/djangoapps/models/ openedx/core/djangoapps/monkey_patch/ openedx/core/djangoapps/oauth_dispatch/ openedx/core/djangoapps/olx_rest_api/ openedx/core/djangoapps/password_policy/ openedx/core/djangoapps/plugin_api/ openedx/core/djangoapps/plugins/ openedx/core/djangoapps/profile_images/ openedx/core/djangoapps/programs/ openedx/core/djangoapps/safe_sessions/ openedx/core/djangoapps/schedules/ openedx/core/djangoapps/service_status/ openedx/core/djangoapps/session_inactivity_timeout/ openedx/core/djangoapps/signals/ openedx/core/djangoapps/site_configuration/ openedx/core/djangoapps/system_wide_roles/ openedx/core/djangoapps/theming/ openedx/core/djangoapps/user_api/ openedx/core/djangoapps/user_authn/ openedx/core/djangoapps/util/ openedx/core/djangoapps/verified_track_content/ openedx/core/djangoapps/video_config/ openedx/core/djangoapps/video_pipeline/ openedx/core/djangoapps/waffle_utils/ openedx/core/djangoapps/xblock/ openedx/core/djangoapps/xmodule_django/ openedx/core/tests/ openedx/features/ openedx/testing/ openedx/tests/ openedx/core/djangoapps/notifications/ openedx/core/djangoapps/staticfiles/ openedx/core/djangoapps/content_tagging/"
23+
path: "openedx/core/djangoapps/geoinfo/ openedx/core/djangoapps/header_control/ openedx/core/djangoapps/heartbeat/ openedx/core/djangoapps/lang_pref/ openedx/core/djangoapps/models/ openedx/core/djangoapps/monkey_patch/ openedx/core/djangoapps/oauth_dispatch/ openedx/core/djangoapps/olx_rest_api/ openedx/core/djangoapps/password_policy/ openedx/core/djangoapps/plugin_api/ openedx/core/djangoapps/plugins/ openedx/core/djangoapps/profile_images/ openedx/core/djangoapps/programs/ openedx/core/djangoapps/safe_sessions/ openedx/core/djangoapps/schedules/ openedx/core/djangoapps/service_status/ openedx/core/djangoapps/session_inactivity_timeout/ openedx/core/djangoapps/signals/ openedx/core/djangoapps/site_configuration/ openedx/core/djangoapps/system_wide_roles/ openedx/core/djangoapps/theming/ openedx/core/djangoapps/user_api/ openedx/core/djangoapps/user_authn/ openedx/core/djangoapps/util/ openedx/core/djangoapps/verified_track_content/ openedx/core/djangoapps/video_config/ openedx/core/djangoapps/video_pipeline/ openedx/core/djangoapps/waffle_utils/ openedx/core/djangoapps/xblock/ openedx/core/djangoapps/xmodule_django/ openedx/core/tests/ openedx/features/ openedx/testing/ openedx/tests/ openedx/envs/ openedx/core/djangoapps/notifications/ openedx/core/djangoapps/staticfiles/ openedx/core/djangoapps/content_tagging/"
2424
- module-name: common
2525
path: "common"
2626
- module-name: cms

cms/envs/common.py

Lines changed: 17 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -45,103 +45,28 @@
4545

4646
from corsheaders.defaults import default_headers as corsheaders_default_headers
4747
from datetime import timedelta
48+
49+
from django.utils.translation import gettext_lazy as _
50+
4851
import lms.envs.common
49-
# Although this module itself may not use these imported variables, other dependent modules may.
50-
# Warning: Do NOT add any new variables to this list. This is incompatible with future plans to
51-
# have more logical separation between LMS and Studio (CMS). It is also incompatible with the
52-
# direction documented in OEP-45: Configuring and Operating Open edX:
53-
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0045-arch-ops-and-config.html
54-
from lms.envs.common import (
55-
USE_TZ, ALL_LANGUAGES, ASSET_IGNORE_REGEX,
56-
PARENTAL_CONSENT_AGE_LIMIT, REGISTRATION_EMAIL_PATTERNS_ALLOWED,
57-
# The following PROFILE_IMAGE_* settings are included as they are
58-
# indirectly accessed through the email opt-in API, which is
59-
# technically accessible through the CMS via legacy URLs.
60-
PROFILE_IMAGE_BACKEND, PROFILE_IMAGE_DEFAULT_FILENAME, PROFILE_IMAGE_DEFAULT_FILE_EXTENSION,
61-
PROFILE_IMAGE_HASH_SEED, PROFILE_IMAGE_MIN_BYTES, PROFILE_IMAGE_MAX_BYTES, PROFILE_IMAGE_SIZES_MAP,
62-
# The following setting is included as it is used to check whether to
63-
# display credit eligibility table on the CMS or not.
64-
COURSE_MODE_DEFAULTS, DEFAULT_COURSE_ABOUT_IMAGE_URL,
65-
66-
# User-uploaded content
67-
MEDIA_ROOT,
68-
MEDIA_URL,
69-
70-
# Lazy Gettext
71-
_,
72-
73-
# Django REST framework configuration
74-
REST_FRAMEWORK,
75-
76-
STATICI18N_OUTPUT_DIR,
77-
78-
# Heartbeat
79-
HEARTBEAT_CHECKS,
80-
HEARTBEAT_EXTENDED_CHECKS,
81-
HEARTBEAT_CELERY_TIMEOUT,
82-
HEARTBEAT_CELERY_ROUTING_KEY,
83-
84-
# Default site to use if no site exists matching request headers
85-
SITE_ID,
86-
87-
# constants for redirects app
88-
REDIRECT_CACHE_TIMEOUT,
89-
REDIRECT_CACHE_KEY_PREFIX,
90-
91-
# This is required for the migrations in oauth_dispatch.models
92-
# otherwise it fails saying this attribute is not present in Settings
93-
# Although Studio does not enable OAuth2 Provider capability, the new approach
94-
# to generating test databases will discover and try to create all tables
95-
# and this setting needs to be present
96-
OAUTH2_PROVIDER_APPLICATION_MODEL,
97-
JWT_AUTH,
98-
99-
USERNAME_REGEX_PARTIAL,
100-
USERNAME_PATTERN,
101-
102-
# django-debug-toolbar
103-
DEBUG_TOOLBAR_PATCH_SETTINGS,
104-
105-
COURSE_ENROLLMENT_MODES,
106-
CONTENT_TYPE_GATE_GROUP_IDS,
107-
108-
DISABLE_ACCOUNT_ACTIVATION_REQUIREMENT_SWITCH,
109-
110-
GENERATE_PROFILE_SCORES,
111-
112-
# Enterprise service settings
113-
ENTERPRISE_CATALOG_INTERNAL_ROOT_URL,
114-
ENTERPRISE_BACKEND_SERVICE_EDX_OAUTH2_KEY,
115-
ENTERPRISE_BACKEND_SERVICE_EDX_OAUTH2_SECRET,
116-
ENTERPRISE_BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL,
117-
118-
# Methods to derive settings
119-
_make_mako_template_dirs,
120-
_make_locale_paths,
121-
122-
# Password Validator Settings
123-
AUTH_PASSWORD_VALIDATORS
124-
)
52+
53+
from openedx.core.constants import COURSE_KEY_REGEX, COURSE_KEY_PATTERN, COURSE_ID_PATTERN
54+
from openedx.envs.common import * # pylint: disable=wildcard-import
55+
12556
from lms.envs.common import (
57+
# NOTE: Do not add any new imports here. Use openedx.envs.common instead for
58+
# platform wide settings.
59+
12660
# FIXME: The HIBP settings are only used in the LMS, but CMS unit tests fail
12761
# without them. Perhaps moving some code would allow us to remove these from
128-
# this file.
62+
# this file. GitHub Issue: https://github.com/openedx/edx-platform/issues/36992.
12963
ENABLE_AUTHN_LOGIN_BLOCK_HIBP_POLICY,
13064
ENABLE_AUTHN_LOGIN_NUDGE_HIBP_POLICY,
13165
ENABLE_AUTHN_REGISTER_HIBP_POLICY,
13266
ENABLE_AUTHN_RESET_PASSWORD_HIBP_POLICY,
13367
HIBP_LOGIN_BLOCK_PASSWORD_FREQUENCY_THRESHOLD,
13468
HIBP_LOGIN_NUDGE_PASSWORD_FREQUENCY_THRESHOLD,
13569
HIBP_REGISTRATION_PASSWORD_FREQUENCY_THRESHOLD,
136-
137-
USE_EXTRACTED_WORD_CLOUD_BLOCK,
138-
USE_EXTRACTED_ANNOTATABLE_BLOCK,
139-
USE_EXTRACTED_POLL_QUESTION_BLOCK,
140-
USE_EXTRACTED_LTI_BLOCK,
141-
USE_EXTRACTED_HTML_BLOCK,
142-
USE_EXTRACTED_DISCUSSION_BLOCK,
143-
USE_EXTRACTED_PROBLEM_BLOCK,
144-
USE_EXTRACTED_VIDEO_BLOCK,
14570
)
14671
from path import Path as path
14772
from django.urls import reverse_lazy
@@ -700,7 +625,7 @@
700625
# Don't look for template source files inside installed applications.
701626
'APP_DIRS': False,
702627
# Instead, look for template source files in these dirs.
703-
'DIRS': Derived(_make_mako_template_dirs),
628+
'DIRS': Derived(make_mako_template_dirs),
704629
# Options specific to this backend.
705630
'OPTIONS': {
706631
'loaders': (
@@ -719,7 +644,7 @@
719644
'NAME': 'mako',
720645
'BACKEND': 'common.djangoapps.edxmako.backend.Mako',
721646
'APP_DIRS': False,
722-
'DIRS': Derived(_make_mako_template_dirs),
647+
'DIRS': Derived(make_mako_template_dirs),
723648
'OPTIONS': {
724649
'context_processors': CONTEXT_PROCESSORS,
725650
'debug': False,
@@ -823,12 +748,6 @@
823748
}
824749
]
825750

826-
# These are standard regexes for pulling out info like course_ids, usage_ids, etc.
827-
# They are used so that URLs with deprecated-format strings still work.
828-
from lms.envs.common import (
829-
COURSE_KEY_PATTERN, COURSE_KEY_REGEX, COURSE_ID_PATTERN, USAGE_KEY_PATTERN, ASSET_KEY_PATTERN
830-
)
831-
832751
######################### CSRF #########################################
833752

834753
# Forwards-compatibility with Django 1.7
@@ -1254,12 +1173,6 @@
12541173
CELERY_TIMEZONE = 'UTC'
12551174
TIME_ZONE = 'UTC'
12561175
LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html
1257-
LANGUAGES_BIDI = lms.envs.common.LANGUAGES_BIDI
1258-
1259-
LANGUAGE_COOKIE_NAME = lms.envs.common.LANGUAGE_COOKIE_NAME
1260-
1261-
LANGUAGES = lms.envs.common.LANGUAGES
1262-
LANGUAGE_DICT = dict(LANGUAGES)
12631176

12641177
# Languages supported for custom course certificate templates
12651178
CERTIFICATE_TEMPLATE_LANGUAGES = {
@@ -1273,8 +1186,6 @@
12731186
STATICI18N_FILENAME_FUNCTION = 'statici18n.utils.legacy_filename'
12741187
STATICI18N_ROOT = PROJECT_ROOT / "static"
12751188

1276-
LOCALE_PATHS = Derived(_make_locale_paths)
1277-
12781189
# Messages
12791190
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
12801191

@@ -1540,6 +1451,10 @@
15401451
CELERY_BROKER_USE_SSL = False
15411452
CELERY_EVENT_QUEUE_TTL = None
15421453

1454+
############################## HEARTBEAT ######################################
1455+
1456+
HEARTBEAT_CELERY_ROUTING_KEY = HIGH_PRIORITY_QUEUE
1457+
15431458
############################## Video ##########################################
15441459

15451460
YOUTUBE = {

0 commit comments

Comments
 (0)