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 2022/11/01 16:28:57 UTC
[airavata-django-portal-commons] 01/02: Simplify merging of settings
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-commons.git
commit 15eed96dd874bbb25c7948388f8bbb62df5836af
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Nov 1 12:28:23 2022 -0400
Simplify merging of settings
---
.../dynamic_apps/__init__.py | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/airavata_django_portal_commons/dynamic_apps/__init__.py b/airavata_django_portal_commons/dynamic_apps/__init__.py
index 2c8692e..1e535d4 100644
--- a/airavata_django_portal_commons/dynamic_apps/__init__.py
+++ b/airavata_django_portal_commons/dynamic_apps/__init__.py
@@ -37,16 +37,19 @@ def merge_setting_dict(default, custom_setting):
)
-def merge_setting(settings_module, setting_name):
- # Merge settings from custom Django apps
- # FIXME: only handles WEBPACK_LOADER additions
+def merge_settings(settings_module):
for custom_django_app in CUSTOM_DJANGO_APPS:
- if hasattr(custom_django_app, "settings"):
+ if hasattr(custom_django_app, "merge_settings"):
+ custom_django_app.merge_settings(settings_module)
+ elif hasattr(custom_django_app, "settings"):
+ # This approach is deprecated, use 'merge_settings' instead
+ # Merge settings from custom Django apps
+ # NOTE: only handles WEBPACK_LOADER additions
+ print(
+ f"{type(custom_django_app).__name__}.settings attr is deprecated, use merge_settings instead"
+ )
s = custom_django_app.settings
merge_setting_dict(
- getattr(settings_module, setting_name), getattr(s, setting_name, {})
+ getattr(settings_module, "WEBPACK_LOADER"),
+ getattr(s, "WEBPACK_LOADER", {}),
)
-
-
-def merge_webpack_loader(settings_module):
- merge_setting(settings_module, "WEBPACK_LOADER")