You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/08/26 21:16:36 UTC
[airavata-django-portal] 02/02: Allow custom Django apps to
contribute to overall settings
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit ffc6a135a22c88e8c8c6af871bb3194cff6f747f
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Aug 26 17:16:23 2019 -0400
Allow custom Django apps to contribute to overall settings
---
django_airavata/settings.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/django_airavata/settings.py b/django_airavata/settings.py
index babba5a..e90e324 100644
--- a/django_airavata/settings.py
+++ b/django_airavata/settings.py
@@ -314,6 +314,25 @@ LOGGING = {
},
}
+
+def merge_setting(default, custom_setting):
+ # FIXME: only handles dict settings, doesn't handle lists
+ if isinstance(custom_setting, dict):
+ for k in custom_setting.keys():
+ if k not in default:
+ default[k] = custom_setting[k]
+ else:
+ raise Exception("Custom django app setting conflicts with "
+ "key {} in {}".format(k, default))
+
+
+# Merge settings from custom Django apps
+# FIXME: only handles WEBPACK_LOADER additions
+for custom_django_app in CUSTOM_DJANGO_APPS:
+ if hasattr(custom_django_app, 'settings'):
+ s = custom_django_app.settings
+ merge_setting(WEBPACK_LOADER, getattr(s, 'WEBPACK_LOADER', {}))
+
# Allow all settings to be overridden by settings_local.py file
try:
from django_airavata.settings_local import * # noqa