mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor
This commit is contained in:
parent
48abd3cf79
commit
279ed78119
@ -753,10 +753,10 @@ for plugin in PLUGIN_DIRS:
|
||||
[PLUGINS.append(item) for item in modules]
|
||||
|
||||
# collect integration plugins
|
||||
INTEGRATION_PLUGINS = {}
|
||||
INTEGRATION_PLUGIN_SETTING = {}
|
||||
INTEGRATION_PLUGIN_LIST = {}
|
||||
INTEGRATION_APPS_LOADED = False # Marks if apps were reloaded yet
|
||||
|
||||
for plugin in inventree_plugins.load_integration_plugins():
|
||||
plugin = plugin()
|
||||
INTEGRATION_PLUGIN_LIST[plugin.slug] = plugin
|
||||
INTEGRATION_PLUGINS[plugin.slug] = plugin
|
||||
|
@ -128,7 +128,7 @@ translated_javascript_urls = [
|
||||
# Integration plugin urls
|
||||
interation_urls = []
|
||||
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'):
|
||||
interation_urls.append(plugin.urlpatterns)
|
||||
|
||||
|
@ -12,7 +12,7 @@ register = template.Library()
|
||||
@register.simple_tag()
|
||||
def plugin_list(*args, **kwargs):
|
||||
""" Return a list of all installed integration plugins """
|
||||
return djangosettings.INTEGRATION_PLUGIN_LIST
|
||||
return djangosettings.INTEGRATION_PLUGINS
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
|
@ -12,13 +12,16 @@ class PluginConfig(AppConfig):
|
||||
|
||||
def ready(self):
|
||||
from common.models import InvenTreeSetting
|
||||
plugins = settings.INTEGRATION_PLUGINS.items()
|
||||
|
||||
# if plugin settings are enabled enhance the settings
|
||||
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'):
|
||||
plugin_setting = plugin.settingspatterns
|
||||
settings.INTEGRATION_PLUGIN_SETTING[slug] = plugin_setting
|
||||
|
||||
# Add to settings dir
|
||||
InvenTreeSetting.GLOBAL_SETTINGS.update(plugin_setting)
|
||||
|
||||
# if plugin apps are enabled
|
||||
@ -27,7 +30,7 @@ class PluginConfig(AppConfig):
|
||||
apps_changed = False
|
||||
|
||||
# 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'):
|
||||
plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(settings.BASE_DIR).parts)
|
||||
settings.INSTALLED_APPS += [plugin_path]
|
||||
|
@ -12,7 +12,7 @@ class PluginTemplateLoader(FilesystemLoader):
|
||||
def get_dirs(self):
|
||||
dirname = 'templates'
|
||||
template_dirs = []
|
||||
for plugin in settings.INTEGRATION_PLUGIN_LIST.values():
|
||||
for plugin in settings.INTEGRATION_PLUGINS.values():
|
||||
new_path = Path(plugin.path) / dirname
|
||||
if Path(new_path).is_dir():
|
||||
template_dirs.append(new_path)
|
||||
|
@ -57,7 +57,7 @@ class PluginTagTests(TestCase):
|
||||
|
||||
def test_tag_plugin_list(self):
|
||||
"""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):
|
||||
"""check all plugins are listed"""
|
||||
|
Loading…
Reference in New Issue
Block a user