From 369f92abf166227f24eb0423c34331905b931d36 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 19 Sep 2021 17:12:16 +0200 Subject: [PATCH] move mixin registry stuff into own class --- InvenTree/plugins/integration/integration.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/InvenTree/plugins/integration/integration.py b/InvenTree/plugins/integration/integration.py index 21aa75d511..23831a747e 100644 --- a/InvenTree/plugins/integration/integration.py +++ b/InvenTree/plugins/integration/integration.py @@ -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