Skip to content

Commit

Permalink
encapsulate dynamic settings default prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Jan 10, 2025
1 parent 63245fe commit 4297ff2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ephios/core/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def __getattr__(self, name):
return None
return result
# default to django settings
return getattr(self._django_settings, f"DEFAULT_{name}")
return getattr(self._django_settings, self.get_default_key(name))

def get_default_key(self, settings_key):
return f"DEFAULT_{settings_key}"


dynamic_settings = DynamicSettingsProxy()
4 changes: 3 additions & 1 deletion ephios/core/templatetags/settings_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def _static_file_exists(path):
def as_brand_static_path(path):
result = os.path.join(dynamic_settings.BRAND_STATIC_PATH, path)
if not _static_file_exists(result):
fallback = os.path.join(settings.DEFAULT_BRAND_STATIC_PATH, path)
fallback = os.path.join(
getattr(settings, dynamic_settings.get_default_key("BRAND_STATIC_PATH")), path
)
logger.warning(f"could not find brand static file '{result}', using '{fallback}' instead")
return fallback
return result

0 comments on commit 4297ff2

Please sign in to comment.