Merge pull request #22702 from cpennington/static-files-s3-configs
Load any AWS_ prefixed settings from ENV_TOKENS to allow S3Boto3Stora…
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user