refactor to make simpler

This commit is contained in:
Matthias 2021-09-18 04:23:31 +02:00
parent 21d187a387
commit debad4ab9a
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -22,9 +22,7 @@ class SettingsMixin:
"""
setup settings for this plugin
"""
if self.SETTINGS:
return self.SETTINGS
return None
return getattr(self, 'SETTINGS', None)
@property
def has_settings(self):
@ -52,9 +50,7 @@ class UrlsMixin:
"""
setup url endpoints for this plugin
"""
if hasattr(self, 'URLS'):
return self.URLS
return None
return getattr(self, 'URLS', None)
@property
def base_url(self):
@ -86,12 +82,10 @@ class IntegrationPlugin(plugin.InvenTreePlugin):
self.add_mixin('base')
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'):
self.mixins = {}
self.mixins[key] = True
if fnc_enabled:
self.mixins[key] = fnc_enabled
self.mixins[key] = fnc_enabled
def module(self, key):
return key in self.mixins