move flags

This commit is contained in:
Matthias 2021-11-20 18:07:05 +01:00
parent 3aa40ce3e9
commit 308348f051
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
3 changed files with 7 additions and 4 deletions

View File

@ -885,7 +885,6 @@ PLUGINS = []
INTEGRATION_PLUGIN_GLOBALSETTING = {}
INTEGRATION_APPS_LOADING = True # Marks if apps were reloaded yet
INTEGRATION_PLUGINS_RELOADING = False
INTEGRATION_APPS_PATHS = [] # Holds all added plugin_paths
INTEGRATION_ERRORS = {} # Holds discovering errors

View File

@ -11,6 +11,6 @@ class PluginAppConfig(AppConfig):
name = 'plugin'
def ready(self):
if not settings.INTEGRATION_PLUGINS_RELOADING:
if not plugins.is_loading:
plugins.collect_plugins()
plugins.load_plugins()

View File

@ -35,9 +35,13 @@ logger = logging.getLogger('inventree')
class Plugins:
def __init__(self) -> None:
# plugin registry
self.plugins = {}
self.plugins_inactive = {}
# flags
self.is_loading = False
# region public plugin functions
def load_plugins(self):
"""load and activate all IntegrationPlugins"""
@ -393,9 +397,9 @@ class Plugins:
apps.clear_cache()
self._try_reload(apps.populate, settings.INSTALLED_APPS)
settings.INTEGRATION_PLUGINS_RELOADING = True
self.is_loading = True
self._try_reload(apps.set_installed_apps, settings.INSTALLED_APPS)
settings.INTEGRATION_PLUGINS_RELOADING = False
self.is_loading = False
def _try_reload(self, cmd, *args, **kwargs):
"""