From 54edfc8b0fe72091920899d99ec82b6ba1a006cf Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 10 Jun 2024 19:44:53 -0400 Subject: [PATCH] naming, cruft, logic nits re: #11009 --- arches/app/utils/thumbnail_factory.py | 1 - arches/settings_utils.py | 30 +++++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/arches/app/utils/thumbnail_factory.py b/arches/app/utils/thumbnail_factory.py index 190d2848305..b09e70bacc4 100644 --- a/arches/app/utils/thumbnail_factory.py +++ b/arches/app/utils/thumbnail_factory.py @@ -19,7 +19,6 @@ import logging import importlib -from django.apps import apps from arches.app.models.system_settings import settings logger = logging.getLogger(__name__) diff --git a/arches/settings_utils.py b/arches/settings_utils.py index 21edc0cf004..73e5960d7f2 100644 --- a/arches/settings_utils.py +++ b/arches/settings_utils.py @@ -10,7 +10,7 @@ @contextmanager -def move_to_end_of_sys_path(*paths): +def _move_to_end_of_sys_path(*paths): _orig_sys_path = sys.path[:] for path in paths: if path in sys.path: @@ -26,18 +26,15 @@ def arches_applications(): from arches import settings as core_settings return [ - mod.name for mod in arches_applications_modules(core_settings.INSTALLED_APPS) + module.name + for module in arches_applications_modules(core_settings.INSTALLED_APPS) ] def arches_applications_modules(installed_apps): - from arches import settings as core_settings - arches_applications_modules = [] for app in installed_apps or []: - if app in core_settings.INSTALLED_APPS: - continue try: config = AppConfig.create(app) except ImportError: @@ -45,7 +42,6 @@ def arches_applications_modules(installed_apps): continue if getattr(config, "is_arches_application", False): arches_applications_modules.append(config.module) - break return arches_applications_modules @@ -151,22 +147,24 @@ def build_templates_config( def transmit_webpack_django_config(**kwargs): - is_core = kwargs["APP_NAME"] == "Arches" - our_settings = {k: v for k, v in kwargs.items() if k.isupper()} + is_arches_core = kwargs["APP_NAME"] == "Arches" + transmitted_project_settings = {k: v for k, v in kwargs.items() if k.isupper()} # We're currently executing APP_NAME's settings.py, # we don't need to try to install it, too. - if not is_core: - our_settings["INSTALLED_APPS"] = list(our_settings["INSTALLED_APPS"]) - our_settings["INSTALLED_APPS"].remove(kwargs["APP_NAME"]) - settings.configure(default_settings=global_settings, **our_settings) + if not is_arches_core: + transmitted_project_settings["INSTALLED_APPS"] = list( + transmitted_project_settings["INSTALLED_APPS"] + ) + transmitted_project_settings["INSTALLED_APPS"].remove(kwargs["APP_NAME"]) + settings.configure(default_settings=global_settings, **transmitted_project_settings) # Without this `import celery` might resolve to arches.celery or project.celery - if is_core: - with move_to_end_of_sys_path(os.path.realpath(kwargs["ROOT_DIR"])): + if is_arches_core: + with _move_to_end_of_sys_path(os.path.realpath(kwargs["ROOT_DIR"])): django.setup() else: - with move_to_end_of_sys_path(os.path.realpath(kwargs["APP_ROOT"])): + with _move_to_end_of_sys_path(os.path.realpath(kwargs["APP_ROOT"])): django.setup() arches_applications_paths = {