Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions credentials/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,14 @@
FILE_STORAGE_BACKEND = {}
EXTRA_APPS = []
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
},
}
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
Expand All @@ -474,7 +481,7 @@
}
API_ROOT = None
MEDIA_STORAGE_BACKEND = {
"DEFAULT_FILE_STORAGE": "django.core.files.storage.FileSystemStorage",
"STORAGES": STORAGES,
"MEDIA_ROOT": MEDIA_ROOT,
"MEDIA_URL": MEDIA_URL,
}
Expand Down
13 changes: 10 additions & 3 deletions credentials/settings/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = "/tmp/credentials-emails"

DEFAULT_FILE_STORAGE = os.environ.get("DEFAULT_FILE_STORAGE", "django.core.files.storage.FileSystemStorage")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultfile_storage = os.environ.get("DEFAULT_FILE_STORAGE", "django.core.files.storage.FileSystemStorage")

if defaultfile_storage:
    STORAGES["default"]["BACKEND"] = defaultfile_storage

MEDIA_URL = os.environ.get("MEDIA_URL", "/media/")
defaultfile_storage = os.environ.get("DEFAULT_FILE_STORAGE")

if defaultfile_storage:
STORAGES["default"]["BACKEND"] = defaultfile_storage

staticfiles_storage = os.environ.get("STATICFILES_STORAGE")

STATICFILES_STORAGE = os.environ.get("STATICFILES_STORAGE", "django.contrib.staticfiles.storage.StaticFilesStorage")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staticfiles_storage = os.environ.get('STATICFILES_STORAGE', 'django.contrib.staticfiles.storage.StaticFilesStorage')

if staticfiles_storage:
    STORAGES["staticfiles"]["BACKEND"] = staticfiles_storage

if staticfiles_storage:
STORAGES["staticfiles"]["BACKEND"] = staticfiles_storage

MEDIA_URL = os.environ.get("MEDIA_URL", "/media/")
STATIC_URL = os.environ.get("STATIC_URL", "/static/")

# OAuth2 variables specific to social-auth/SSO login use case.
Expand Down
11 changes: 11 additions & 0 deletions credentials/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@

vars().update(config_from_yaml)

FILE_STORAGE_BACKEND = config_from_yaml.get("FILE_STORAGE_BACKEND", {})
default_backend = FILE_STORAGE_BACKEND.pop("DEFAULT_FILE_STORAGE", None)
static_backend = FILE_STORAGE_BACKEND.pop("STATICFILES_STORAGE", None)

# Load the files storage backend settings for django storages
# In django==4.2.24 following line sets the DEFAULT_FILE_STORAGE and other AWS variables as per YAML.
vars().update(FILE_STORAGE_BACKEND)

if default_backend:
STORAGES["default"]["BACKEND"] = default_backend

if static_backend:
STORAGES["staticfiles"]["BACKEND"] = static_backend

# make sure this happens after the configuration file overrides so format string can be overridden
LOGGING = get_logger_config(format_string=LOGGING_FORMAT_STRING)

Expand Down
3 changes: 1 addition & 2 deletions credentials/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# Local Directories
TEST_ROOT = path("test_root")
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"

MEDIA_ROOT = str(TEST_ROOT / "uploads")
MEDIA_URL = "/static/uploads/"

Expand All @@ -49,7 +49,6 @@
"JWT_AUDIENCE": SOCIAL_AUTH_EDX_OAUTH2_KEY,
}
)
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"

# Verifiable Credentials
ENABLE_VERIFIABLE_CREDENTIALS = True
Expand Down