diff --git a/InvenTree/plugin/plugin.py b/InvenTree/plugin/plugin.py index 703482089e..0eefe42080 100644 --- a/InvenTree/plugin/plugin.py +++ b/InvenTree/plugin/plugin.py @@ -121,6 +121,26 @@ class MixinBase: self._mixins = {} super().__init__(*args, **kwargs) + def mixin(self, key): + """ + Check if mixin is registered + """ + return key in self._mixins + + def mixin_enabled(self, key): + """ + Check if mixin is registered, enabled and ready + """ + if self.mixin(key): + fnc_name = self._mixins.get(key) + + # Allow for simple case where the mixin is "always" ready + if fnc_name is True: + return True + + return getattr(self, fnc_name, True) + return False + def add_mixin(self, key: str, fnc_enabled=True, cls=None): """ Add a mixin to the plugins registry @@ -274,28 +294,6 @@ class InvenTreePlugin(MixinBase, MetaBase): """ return f'{reverse("settings")}#select-plugin-{self.slug}' - # region mixins - def mixin(self, key): - """ - Check if mixin is registered - """ - return key in self._mixins - - def mixin_enabled(self, key): - """ - Check if mixin is registered, enabled and ready - """ - if self.mixin(key): - fnc_name = self._mixins.get(key) - - # Allow for simple case where the mixin is "always" ready - if fnc_name is True: - return True - - return getattr(self, fnc_name, True) - return False - # endregion - # region package info def _get_package_commit(self): """