mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor to make simpler
This commit is contained in:
parent
21d187a387
commit
debad4ab9a
@ -22,9 +22,7 @@ class SettingsMixin:
|
|||||||
"""
|
"""
|
||||||
setup settings for this plugin
|
setup settings for this plugin
|
||||||
"""
|
"""
|
||||||
if self.SETTINGS:
|
return getattr(self, 'SETTINGS', None)
|
||||||
return self.SETTINGS
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_settings(self):
|
def has_settings(self):
|
||||||
@ -52,9 +50,7 @@ class UrlsMixin:
|
|||||||
"""
|
"""
|
||||||
setup url endpoints for this plugin
|
setup url endpoints for this plugin
|
||||||
"""
|
"""
|
||||||
if hasattr(self, 'URLS'):
|
return getattr(self, 'URLS', None)
|
||||||
return self.URLS
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def base_url(self):
|
def base_url(self):
|
||||||
@ -86,12 +82,10 @@ class IntegrationPlugin(plugin.InvenTreePlugin):
|
|||||||
self.add_mixin('base')
|
self.add_mixin('base')
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def add_mixin(self, key: str, fnc_enabled=None):
|
def add_mixin(self, key: str, fnc_enabled=True):
|
||||||
if not hasattr(self, 'mixins'):
|
if not hasattr(self, 'mixins'):
|
||||||
self.mixins = {}
|
self.mixins = {}
|
||||||
self.mixins[key] = True
|
self.mixins[key] = fnc_enabled
|
||||||
if fnc_enabled:
|
|
||||||
self.mixins[key] = fnc_enabled
|
|
||||||
|
|
||||||
def module(self, key):
|
def module(self, key):
|
||||||
return key in self.mixins
|
return key in self.mixins
|
||||||
|
Loading…
Reference in New Issue
Block a user