diff --git a/cms/envs/common.py b/cms/envs/common.py index c2f77d38da..8bffb25198 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -935,6 +935,7 @@ PIPELINE = { } STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage' +STATICFILES_STORAGE_KWARGS = {} # List of finder classes that know how to find static files in various locations. # Note: the pipeline finder is included to be able to discover optimized files diff --git a/cms/envs/production.py b/cms/envs/production.py index b4604bf34e..a2228bf117 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -214,6 +214,12 @@ if 'staticfiles' in CACHES: # managed by the yaml file contents STATICFILES_STORAGE = os.environ.get('STATICFILES_STORAGE', ENV_TOKENS.get('STATICFILES_STORAGE', STATICFILES_STORAGE)) +# Load all AWS_ prefixed variables to allow an S3Boto3Storage to be configured +_locals = locals() +for key, value in ENV_TOKENS.items(): + if key.startswith('AWS_'): + _locals[key] = value + SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN') SESSION_COOKIE_HTTPONLY = ENV_TOKENS.get('SESSION_COOKIE_HTTPONLY', True) SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE) diff --git a/lms/envs/common.py b/lms/envs/common.py index 115dcfb989..0443f9d2ab 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1548,6 +1548,7 @@ PIPELINE = { } STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage' +STATICFILES_STORAGE_KWARGS = {} # List of finder classes that know how to find static files in various locations. # Note: the pipeline finder is included to be able to discover optimized files diff --git a/lms/envs/production.py b/lms/envs/production.py index 8292f1a66e..4fe8e2b9ff 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -250,6 +250,12 @@ if 'staticfiles' in CACHES: # managed by the yaml file contents STATICFILES_STORAGE = os.environ.get('STATICFILES_STORAGE', ENV_TOKENS.get('STATICFILES_STORAGE', STATICFILES_STORAGE)) +# Load all AWS_ prefixed variables to allow an S3Boto3Storage to be configured +_locals = locals() +for key, value in ENV_TOKENS.items(): + if key.startswith('AWS_'): + _locals[key] = value + # Email overrides DEFAULT_FROM_EMAIL = ENV_TOKENS.get('DEFAULT_FROM_EMAIL', DEFAULT_FROM_EMAIL) DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBACK_EMAIL) diff --git a/openedx/core/storage.py b/openedx/core/storage.py index 885e8a62ce..fefad2ee4a 100644 --- a/openedx/core/storage.py +++ b/openedx/core/storage.py @@ -3,6 +3,7 @@ Django storage backends for Open edX. """ +from django.conf import settings from django.contrib.staticfiles.storage import StaticFilesStorage from django.core.files.storage import get_storage_class, FileSystemStorage from django.utils.deconstruct import deconstructible @@ -51,7 +52,9 @@ class ProductionMixin( can be applied over an existing Storage. We use this version on production. """ - pass + def __init__(self, *args, **kwargs): + kwargs.update(settings.STATICFILES_STORAGE_KWARGS.get(settings.STATICFILES_STORAGE, {})) + super(ProductionMixin, self).__init__(*args, **kwargs) class ProductionStorage(ProductionMixin, StaticFilesStorage):