From e11e9d9073ef295df12c10aa78578ac065414dcd Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 3 Jan 2020 12:14:02 -0500 Subject: [PATCH] Allow overriding ProductionStorage and ProductionS3Storage kwargs with a django settings value --- cms/envs/common.py | 1 + lms/envs/common.py | 1 + openedx/core/storage.py | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) 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/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/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):