setting to control plugin settings ingestion

This commit is contained in:
Matthias 2021-10-16 04:17:48 +02:00
parent 952e7e4554
commit c16c26c496
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
4 changed files with 27 additions and 6 deletions

View File

@ -266,6 +266,7 @@ INSTALLED_APPS = [
'report.apps.ReportConfig',
'stock.apps.StockConfig',
'users.apps.UsersConfig',
'plugin.apps.PluginConfig',
'InvenTree.apps.InvenTreeConfig', # InvenTree app runs last
# Third part add-ons
@ -764,11 +765,6 @@ for plugin in inventree_plugins.load_integration_plugins():
INTEGRATION_PLUGINS.append(plugin)
INTEGRATION_PLUGIN_LIST[plugin.slug] = plugin
if plugin.mixin_enabled('settings'):
plugin_setting = plugin.settingspatterns
INTEGRATION_PLUGIN_SETTING[plugin.slug] = plugin_setting
INTEGRATION_PLUGIN_SETTINGS.update(plugin_setting)
if plugin.mixin_enabled('app'):
plugin_path = '.'.join(pathlib.Path(plugin.path).relative_to(BASE_DIR).parts)

View File

@ -866,7 +866,12 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': False,
'validator': bool,
},
**settings.INTEGRATION_PLUGIN_SETTINGS,
'ENABLE_PLUGINS_SETTING': {
'name': _('Enable setting integration'),
'description': _('Enable plugins to integrate into inventree settings'),
'default': False,
'validator': bool,
},
}
class Meta:

19
InvenTree/plugin/apps.py Normal file
View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
from django.conf import settings
class PluginConfig(AppConfig):
name = 'plugin'
def ready(self):
from common.models import InvenTreeSetting
if InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'):
for slug, plugin in settings.INTEGRATION_PLUGIN_LIST.items():
if plugin.mixin_enabled('settings'):
plugin_setting = plugin.settingspatterns
settings.INTEGRATION_PLUGIN_SETTING[slug] = plugin_setting
settings.INTEGRATION_PLUGIN_SETTINGS.update(plugin_setting)

View File

@ -18,6 +18,7 @@
<tbody>
{% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_URL" %}
{% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_NAVIGATION" %}
{% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_SETTING"%}
</tbody>
</table>