mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
one module check fnc
This commit is contained in:
parent
0cae3633d2
commit
21d187a387
@ -661,6 +661,6 @@ INTEGRATION_PLUGIN_LIST = {}
|
|||||||
for plugin in INTEGRATION_PLUGINS:
|
for plugin in INTEGRATION_PLUGINS:
|
||||||
plugin = plugin()
|
plugin = plugin()
|
||||||
INTEGRATION_PLUGIN_LIST[plugin.plugin_name()] = plugin
|
INTEGRATION_PLUGIN_LIST[plugin.plugin_name()] = plugin
|
||||||
if plugin.module('settings') and plugin.has_settings:
|
if plugin.module_enabled('settings'):
|
||||||
INTEGRATION_PLUGIN_SETTING[plugin.plugin_name()] = plugin.settingspatterns
|
INTEGRATION_PLUGIN_SETTING[plugin.plugin_name()] = plugin.settingspatterns
|
||||||
INTEGRATION_PLUGIN_SETTINGS.update(plugin.settingspatterns)
|
INTEGRATION_PLUGIN_SETTINGS.update(plugin.settingspatterns)
|
||||||
|
@ -133,7 +133,7 @@ interation_urls = []
|
|||||||
for plugin in integration_plugins:
|
for plugin in integration_plugins:
|
||||||
# initialize
|
# initialize
|
||||||
plugin = plugin()
|
plugin = plugin()
|
||||||
if plugin.module('urls') and plugin.has_urls:
|
if plugin.module_enabled('urls'):
|
||||||
interation_urls.append(plugin.urlpatterns)
|
interation_urls.append(plugin.urlpatterns)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -15,7 +15,7 @@ class SettingsMixin:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.add_mixin('settings')
|
self.add_mixin('settings', 'has_settings')
|
||||||
self.settings = self.setup_settings()
|
self.settings = self.setup_settings()
|
||||||
|
|
||||||
def setup_settings(self):
|
def setup_settings(self):
|
||||||
@ -45,15 +45,15 @@ class UrlsMixin:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.add_mixin('urls')
|
self.add_mixin('urls', 'has_urls')
|
||||||
self.urls = self.setup_urls()
|
self.urls = self.setup_urls()
|
||||||
|
|
||||||
def setup_urls(self):
|
def setup_urls(self):
|
||||||
"""
|
"""
|
||||||
setup url endpoints for this plugin
|
setup url endpoints for this plugin
|
||||||
"""
|
"""
|
||||||
if self.urlpatterns:
|
if hasattr(self, 'URLS'):
|
||||||
return self.urlpatterns
|
return self.URLS
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -86,10 +86,18 @@ class IntegrationPlugin(plugin.InvenTreePlugin):
|
|||||||
self.add_mixin('base')
|
self.add_mixin('base')
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def add_mixin(self, key: str):
|
def add_mixin(self, key: str, fnc_enabled=None):
|
||||||
if not hasattr(self, 'mixins'):
|
if not hasattr(self, 'mixins'):
|
||||||
self.mixins = {}
|
self.mixins = {}
|
||||||
self.mixins[key] = True
|
self.mixins[key] = True
|
||||||
|
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
|
||||||
|
|
||||||
|
def module_enabled(self, key):
|
||||||
|
if self.module(key):
|
||||||
|
fnc_name = self.mixins.get(key)
|
||||||
|
return getattr(self, fnc_name, True)
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user