mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
move globalsettings mixin reg to registry
This commit is contained in:
parent
b1fbac925d
commit
71f74f9cc4
@ -882,7 +882,6 @@ if DEBUG or TESTING:
|
||||
PLUGIN_DIRS.append('plugin.samples')
|
||||
|
||||
PLUGINS = []
|
||||
INTEGRATION_PLUGIN_GLOBALSETTING = {}
|
||||
|
||||
# Test settings
|
||||
PLUGIN_TESTING = get_setting('PLUGIN_TESTING', TESTING) # used to force enable everything plugin
|
||||
|
@ -45,6 +45,8 @@ class Plugins:
|
||||
|
||||
# integration specific
|
||||
self.installed_apps = [] # Holds all added plugin_paths
|
||||
# mixins
|
||||
self.mixins_globalsettings = {}
|
||||
|
||||
self.errors = {} # Holds discovering errors
|
||||
|
||||
@ -228,7 +230,7 @@ class Plugins:
|
||||
for slug, plugin in plugins:
|
||||
if plugin.mixin_enabled('globalsettings'):
|
||||
plugin_setting = plugin.globalsettingspatterns
|
||||
settings.INTEGRATION_PLUGIN_GLOBALSETTING[slug] = plugin_setting
|
||||
self.mixins_globalsettings[slug] = plugin_setting
|
||||
|
||||
# Add to settings dir
|
||||
InvenTreeSetting.GLOBAL_SETTINGS.update(plugin_setting)
|
||||
@ -238,7 +240,7 @@ class Plugins:
|
||||
|
||||
# collect all settings
|
||||
plugin_settings = {}
|
||||
for _, plugin_setting in settings.INTEGRATION_PLUGIN_GLOBALSETTING.items():
|
||||
for _, plugin_setting in self.mixins_globalsettings.items():
|
||||
plugin_settings.update(plugin_setting)
|
||||
|
||||
# remove settings
|
||||
@ -246,7 +248,7 @@ class Plugins:
|
||||
InvenTreeSetting.GLOBAL_SETTINGS.pop(setting)
|
||||
|
||||
# clear cache
|
||||
settings.INTEGRATION_PLUGIN_GLOBALSETTING = {}
|
||||
self.mixins_globalsettings = {}
|
||||
# endregion
|
||||
|
||||
# region integration_app
|
||||
|
@ -28,7 +28,7 @@ def inactive_plugin_list(*args, **kwargs):
|
||||
@register.simple_tag()
|
||||
def plugin_globalsettings(plugin, *args, **kwargs):
|
||||
""" Return a list of all global settings for a plugin """
|
||||
return djangosettings.INTEGRATION_PLUGIN_GLOBALSETTING.get(plugin)
|
||||
return plugin_reg.mixins_globalsettings.get(plugin)
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
|
@ -62,7 +62,10 @@ class PluginTagTests(TestCase):
|
||||
|
||||
def test_tag_plugin_globalsettings(self):
|
||||
"""check all plugins are listed"""
|
||||
self.assertEqual(plugin_tags.plugin_globalsettings(self.sample), settings.INTEGRATION_PLUGIN_GLOBALSETTING.get(self.sample))
|
||||
self.assertEqual(
|
||||
plugin_tags.plugin_globalsettings(self.sample),
|
||||
plugin_reg.mixins_globalsettings.get(self.sample)
|
||||
)
|
||||
|
||||
def test_tag_mixin_enabled(self):
|
||||
"""check that mixin enabled functions work"""
|
||||
|
Loading…
Reference in New Issue
Block a user