This commit is contained in:
Matthias 2021-10-17 04:47:10 +02:00
parent 48abd3cf79
commit 279ed78119
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
6 changed files with 11 additions and 8 deletions

View File

@ -753,10 +753,10 @@ for plugin in PLUGIN_DIRS:
[PLUGINS.append(item) for item in modules] [PLUGINS.append(item) for item in modules]
# collect integration plugins # collect integration plugins
INTEGRATION_PLUGINS = {}
INTEGRATION_PLUGIN_SETTING = {} INTEGRATION_PLUGIN_SETTING = {}
INTEGRATION_PLUGIN_LIST = {}
INTEGRATION_APPS_LOADED = False # Marks if apps were reloaded yet INTEGRATION_APPS_LOADED = False # Marks if apps were reloaded yet
for plugin in inventree_plugins.load_integration_plugins(): for plugin in inventree_plugins.load_integration_plugins():
plugin = plugin() plugin = plugin()
INTEGRATION_PLUGIN_LIST[plugin.slug] = plugin INTEGRATION_PLUGINS[plugin.slug] = plugin

View File

@ -128,7 +128,7 @@ translated_javascript_urls = [
# Integration plugin urls # Integration plugin urls
interation_urls = [] interation_urls = []
if InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'): if InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'):
for plugin in settings.INTEGRATION_PLUGIN_LIST.values(): for plugin in settings.INTEGRATION_PLUGINS.values():
if plugin.mixin_enabled('urls'): if plugin.mixin_enabled('urls'):
interation_urls.append(plugin.urlpatterns) interation_urls.append(plugin.urlpatterns)

View File

@ -12,7 +12,7 @@ register = template.Library()
@register.simple_tag() @register.simple_tag()
def plugin_list(*args, **kwargs): def plugin_list(*args, **kwargs):
""" Return a list of all installed integration plugins """ """ Return a list of all installed integration plugins """
return djangosettings.INTEGRATION_PLUGIN_LIST return djangosettings.INTEGRATION_PLUGINS
@register.simple_tag() @register.simple_tag()

View File

@ -12,13 +12,16 @@ class PluginConfig(AppConfig):
def ready(self): def ready(self):
from common.models import InvenTreeSetting from common.models import InvenTreeSetting
plugins = settings.INTEGRATION_PLUGINS.items()
# if plugin settings are enabled enhance the settings # if plugin settings are enabled enhance the settings
if InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'): if InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'):
for slug, plugin in settings.INTEGRATION_PLUGIN_LIST.items(): for slug, plugin in plugins:
if plugin.mixin_enabled('settings'): if plugin.mixin_enabled('settings'):
plugin_setting = plugin.settingspatterns plugin_setting = plugin.settingspatterns
settings.INTEGRATION_PLUGIN_SETTING[slug] = plugin_setting settings.INTEGRATION_PLUGIN_SETTING[slug] = plugin_setting
# Add to settings dir
InvenTreeSetting.GLOBAL_SETTINGS.update(plugin_setting) InvenTreeSetting.GLOBAL_SETTINGS.update(plugin_setting)
# if plugin apps are enabled # if plugin apps are enabled
@ -27,7 +30,7 @@ class PluginConfig(AppConfig):
apps_changed = False apps_changed = False
# add them to the INSTALLED_APPS # add them to the INSTALLED_APPS
for slug, plugin in settings.INTEGRATION_PLUGIN_LIST.items(): for slug, plugin in plugins:
if plugin.mixin_enabled('app'): if plugin.mixin_enabled('app'):
plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts) plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts)
settings.INSTALLED_APPS += [plugin_path] settings.INSTALLED_APPS += [plugin_path]

View File

@ -12,7 +12,7 @@ class PluginTemplateLoader(FilesystemLoader):
def get_dirs(self): def get_dirs(self):
dirname = 'templates' dirname = 'templates'
template_dirs = [] template_dirs = []
for plugin in settings.INTEGRATION_PLUGIN_LIST.values(): for plugin in settings.INTEGRATION_PLUGINS.values():
new_path = Path(plugin.path) / dirname new_path = Path(plugin.path) / dirname
if Path(new_path).is_dir(): if Path(new_path).is_dir():
template_dirs.append(new_path) template_dirs.append(new_path)

View File

@ -57,7 +57,7 @@ class PluginTagTests(TestCase):
def test_tag_plugin_list(self): def test_tag_plugin_list(self):
"""test that all plugins are listed""" """test that all plugins are listed"""
self.assertEqual(plugin_tags.plugin_list(), settings.INTEGRATION_PLUGIN_LIST) self.assertEqual(plugin_tags.plugin_list(), settings.INTEGRATION_PLUGINS)
def test_tag_plugin_settings(self): def test_tag_plugin_settings(self):
"""check all plugins are listed""" """check all plugins are listed"""