2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-30 18:50:53 +00:00

Allow registry.with_mixin to filter by active status

This commit is contained in:
Oliver
2022-05-19 11:00:31 +10:00
parent ebcb9685b5
commit 11b21a9cca
4 changed files with 12 additions and 3 deletions

View File

@ -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