From 9ecf9603d6c29c3b89390f56b62a825d06af8eec Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 Nov 2021 23:08:28 +0100 Subject: [PATCH] load django internal reloading mechanisms --- InvenTree/InvenTree/settings.py | 1 + InvenTree/plugin/apps.py | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index fb26da332f..31a11e2b4c 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -866,6 +866,7 @@ INTEGRATION_PLUGINS_INACTIVE = {} INTEGRATION_PLUGIN_GLOBALSETTING = {} INTEGRATION_APPS_LOADED = False # Marks if apps were reloaded yet +INTEGRATION_PLUGINS_RELOADING = False INTEGRATION_APPS_PATHS = [] # Holds all added plugin_paths # Test settings diff --git a/InvenTree/plugin/apps.py b/InvenTree/plugin/apps.py index 533c2df108..a73e7aec1a 100644 --- a/InvenTree/plugin/apps.py +++ b/InvenTree/plugin/apps.py @@ -26,8 +26,9 @@ class PluginAppConfig(AppConfig): name = 'plugin' def ready(self): - self._collect_plugins() - self.load_plugins() + if not settings.INTEGRATION_PLUGINS_RELOADING: + self._collect_plugins() + self.load_plugins() # region public plugin functions def load_plugins(self): @@ -224,10 +225,8 @@ class PluginAppConfig(AppConfig): print('done') def _reload_apps(self): - # TODO this is a bit jankey to be honest - apps.app_configs = OrderedDict() - apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False - apps.clear_cache() - apps.populate(settings.INSTALLED_APPS) + settings.INTEGRATION_PLUGINS_RELOADING = True + apps.set_installed_apps(settings.INSTALLED_APPS) + settings.INTEGRATION_PLUGINS_RELOADING = False # endregion # endregion