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:
|
if not plugin:
|
||||||
# Cannot find associated plugin model, return
|
# Cannot find associated plugin model, return
|
||||||
|
logger.error(f"Plugin configuration not found for plugin '{self.slug}'")
|
||||||
return # pragma: no cover
|
return # pragma: no cover
|
||||||
|
|
||||||
PluginSetting.set_setting(key, value, user, plugin=plugin)
|
PluginSetting.set_setting(key, value, user, plugin=plugin)
|
||||||
|
@ -243,7 +243,7 @@ class PluginsRegistry:
|
|||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region registry functions
|
# 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
|
Returns reference to all plugins that have a specified mixin enabled
|
||||||
"""
|
"""
|
||||||
@ -251,6 +251,14 @@ class PluginsRegistry:
|
|||||||
|
|
||||||
for plugin in self.plugins.values():
|
for plugin in self.plugins.values():
|
||||||
if plugin.mixin_enabled(mixin):
|
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)
|
result.append(plugin)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -58,7 +58,7 @@ class CustomPanelSample(PanelMixin, SettingsMixin, InvenTreePlugin):
|
|||||||
|
|
||||||
panels = [
|
panels = [
|
||||||
{
|
{
|
||||||
# This panel will not be displayed, as it is missing the 'content' key
|
# Simple panel without any actual content
|
||||||
'title': 'No Content',
|
'title': 'No Content',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -29,7 +29,7 @@ class InvenTreePluginViewMixin:
|
|||||||
|
|
||||||
panels = []
|
panels = []
|
||||||
|
|
||||||
for plug in registry.with_mixin('panel'):
|
for plug in registry.with_mixin('panel', active=True):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
panels += plug.render_panels(self, self.request, ctx)
|
panels += plug.render_panels(self, self.request, ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user