mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
move mixin registry stuff into own class
This commit is contained in:
parent
5ce525400d
commit
369f92abf1
@ -11,6 +11,15 @@ import plugins.plugin as plugin
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
|
||||
class MixinBase:
|
||||
"""general base for mixins"""
|
||||
|
||||
def add_mixin(self, key: str, fnc_enabled=True, cls=None):
|
||||
if not hasattr(self, '_mixins'):
|
||||
self._mixins = {}
|
||||
self._mixins[key] = fnc_enabled
|
||||
|
||||
|
||||
# region mixins
|
||||
class SettingsMixin:
|
||||
"""Mixin that enables settings for the plugin"""
|
||||
@ -101,7 +110,7 @@ class NavigationMixin:
|
||||
# endregion
|
||||
|
||||
|
||||
class IntegrationPlugin(plugin.InvenTreePlugin):
|
||||
class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin):
|
||||
"""
|
||||
The IntegrationPlugin class is used to integrate with 3rd party software
|
||||
"""
|
||||
@ -109,11 +118,6 @@ class IntegrationPlugin(plugin.InvenTreePlugin):
|
||||
def __init__(self):
|
||||
self.add_mixin('base')
|
||||
|
||||
def add_mixin(self, key: str, fnc_enabled=True):
|
||||
if not hasattr(self, '_mixins'):
|
||||
self._mixins = {}
|
||||
self._mixins[key] = fnc_enabled
|
||||
|
||||
def mixin(self, key):
|
||||
return key in self._mixins
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user