mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow registry.with_mixin to filter by active status
This commit is contained in:
parent
ebcb9685b5
commit
11b21a9cca
@ -60,6 +60,7 @@ class SettingsMixin:
|
||||
|
||||
if not plugin:
|
||||
# Cannot find associated plugin model, return
|
||||
logger.error(f"Plugin configuration not found for plugin '{self.slug}'")
|
||||
return # pragma: no cover
|
||||
|
||||
PluginSetting.set_setting(key, value, user, plugin=plugin)
|
||||
|
@ -243,7 +243,7 @@ class PluginsRegistry:
|
||||
# endregion
|
||||
|
||||
# region registry functions
|
||||
def with_mixin(self, mixin: str):
|
||||
def with_mixin(self, mixin: str, active=None):
|
||||
"""
|
||||
Returns reference to all plugins that have a specified mixin enabled
|
||||
"""
|
||||
@ -251,6 +251,14 @@ class PluginsRegistry:
|
||||
|
||||
for plugin in self.plugins.values():
|
||||
if plugin.mixin_enabled(mixin):
|
||||
|
||||
if active is not None:
|
||||
# Filter by 'enabled' status
|
||||
config = plugin.plugin_config()
|
||||
|
||||
if config.active != active:
|
||||
continue
|
||||
|
||||
result.append(plugin)
|
||||
|
||||
return result
|
||||
|
@ -58,7 +58,7 @@ class CustomPanelSample(PanelMixin, SettingsMixin, InvenTreePlugin):
|
||||
|
||||
panels = [
|
||||
{
|
||||
# This panel will not be displayed, as it is missing the 'content' key
|
||||
# Simple panel without any actual content
|
||||
'title': 'No Content',
|
||||
}
|
||||
]
|
||||
|
@ -29,7 +29,7 @@ class InvenTreePluginViewMixin:
|
||||
|
||||
panels = []
|
||||
|
||||
for plug in registry.with_mixin('panel'):
|
||||
for plug in registry.with_mixin('panel', active=True):
|
||||
|
||||
try:
|
||||
panels += plug.render_panels(self, self.request, ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user