From f13507e23c8b97f84d853dca8b6e1446fb3cc664 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 Nov 2021 22:16:45 +0100 Subject: [PATCH] refactor --- InvenTree/plugin/apps.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/InvenTree/plugin/apps.py b/InvenTree/plugin/apps.py index 3fd88021b4..533c2df108 100644 --- a/InvenTree/plugin/apps.py +++ b/InvenTree/plugin/apps.py @@ -179,12 +179,7 @@ class PluginAppConfig(AppConfig): # add them to the INSTALLED_APPS for slug, plugin in plugins: if plugin.mixin_enabled('app'): - try: - # for local path plugins - plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts) - except ValueError: - # plugin is shipped as package - plugin_path = plugin.PLUGIN_NAME + plugin_path = self._get_plugin_path(plugin) if plugin_path not in settings.INSTALLED_APPS: settings.INSTALLED_APPS += [plugin_path] settings.INTEGRATION_APPS_PATHS += [plugin_path] @@ -196,6 +191,15 @@ class PluginAppConfig(AppConfig): # update urls self._update_urls() + def _get_plugin_path(self, plugin): + try: + # for local path plugins + plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts) + except ValueError: + # plugin is shipped as package + plugin_path = plugin.PLUGIN_NAME + return plugin_path + def deactivate_integration_app(self): # remove plugin from installed_apps for plugin in settings.INTEGRATION_APPS_PATHS: