Merge branch 'adapt-old-config' into 'devel'

fix: resolve backward compability in config

See merge request oliver/ivatar!209
This commit is contained in:
Oliver Falk
2022-09-15 17:03:07 +00:00
4 changed files with 55 additions and 20 deletions

View File

@@ -255,3 +255,18 @@ TRUSTED_DEFAULT_URLS = [
# This MUST BE THE LAST!
if os.path.isfile(os.path.join(BASE_DIR, "config_local.py")):
from config_local import * # noqa # flake8: noqa # NOQA # pragma: no cover
def map_legacy_config(trusted_url):
"""
For backward compability with the legacy configuration
for trusting URLs. Adapts them to fit the new config.
"""
if isinstance(trusted_url, str):
return {
"url_prefix": trusted_url
}
return trusted_url
# Backward compability for legacy behavior
TRUSTED_DEFAULT_URLS = list(map(map_legacy_config, TRUSTED_DEFAULT_URLS))