Skip to content

Commit 1705ed8

Browse files
committed
fix: Make MEDIA_ROOT and DATA_DIR overridable.
The two settings were previously hardcoded in the lms and openedx common.py making it hard to make reasonable defaults using the ENV_ROOT setting.
1 parent 93fad31 commit 1705ed8

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lms/envs/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@
745745
ENV_ROOT = REPO_ROOT.dirname() # virtualenv dir /edx-platform is in
746746
COURSES_ROOT = ENV_ROOT / "data"
747747
NODE_MODULES_ROOT = REPO_ROOT / "node_modules"
748+
MEDIA_ROOT = ENV_ROOT / "media_root"
748749

749750
DATA_DIR = COURSES_ROOT
750751

@@ -936,8 +937,6 @@
936937

937938
ALTERNATE_WORKER_QUEUES = 'cms'
938939

939-
DATA_DIR = '/edx/var/edxapp/data'
940-
941940
# .. setting_name: MAINTENANCE_BANNER_TEXT
942941
# .. setting_default: None
943942
# .. setting_description: Specifies the text that is rendered on the maintenance banner.

lms/envs/development.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@
7777
SESSION_COOKIE_DOMAIN = '.local.openedx.io'
7878

7979
# MFE Development URLs
80+
# This one needs a trailing slash to load correctly right now.
8081
LEARNER_HOME_MICROFRONTEND_URL = 'http://apps.local.openedx.io:1996/learner-dashboard/'
81-
LEARNING_MICROFRONTEND_URL = "http://apps.local.openedx.io:2000/learning/"
82+
# This one explicitly needs to not have a trailing slash because of how it's used to make other
83+
# urls.
84+
LEARNING_MICROFRONTEND_URL = "http://apps.local.openedx.io:2000/learning"
8285

8386
#######################################################################################################################
8487
#### DERIVE ANY DERIVED SETTINGS

lms/envs/production.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
# A proxy for feature flags stored in the settings namespace
3838
FEATURES = FeaturesProxy(globals())
3939

40+
# Settings moved from common.py
41+
DATA_DIR = '/edx/var/edxapp/data'
42+
MEDIA_ROOT = '/edx/var/edxapp/media/'
4043

4144
def get_env_setting(setting):
4245
""" Get the environment setting or return exception """

openedx/envs/common.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def _make_locale_paths(settings):
9696
USE_TZ = True
9797

9898
# User-uploaded content
99-
MEDIA_ROOT = '/edx/var/edxapp/media/'
10099
MEDIA_URL = '/media/'
101100

102101
# Dummy secret key for dev/test
@@ -1304,7 +1303,7 @@ def _make_locale_paths(settings):
13041303
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
13051304
# STORAGE_KWARGS=dict(bucket='video-image-bucket'),
13061305
STORAGE_KWARGS=dict(
1307-
location=MEDIA_ROOT,
1306+
location=Derived(lambda settings: settings.MEDIA_ROOT),
13081307
),
13091308
DIRECTORY_PREFIX='video-images/',
13101309
BASE_URL=MEDIA_URL,
@@ -1321,7 +1320,7 @@ def _make_locale_paths(settings):
13211320
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
13221321
# STORAGE_KWARGS=dict(bucket='video-transcripts-bucket'),
13231322
STORAGE_KWARGS=dict(
1324-
location=MEDIA_ROOT,
1323+
location=Derived(lambda settings: settings.MEDIA_ROOT),
13251324
),
13261325
DIRECTORY_PREFIX='video-transcripts/',
13271326
BASE_URL=MEDIA_URL,
@@ -1611,7 +1610,7 @@ def _make_locale_paths(settings):
16111610
PROFILE_IMAGE_BACKEND = {
16121611
'class': 'openedx.core.storage.OverwriteStorage',
16131612
'options': {
1614-
'location': os.path.join(MEDIA_ROOT, 'profile-images/'),
1613+
'location': Derived(lambda settings: os.path.join(settings.MEDIA_ROOT, 'profile-images/')),
16151614
'base_url': os.path.join(MEDIA_URL, 'profile-images/'),
16161615
},
16171616
}

0 commit comments

Comments
 (0)