From 952e7e4554dbfcf5c55d2127897dc4181819c2b3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Oct 2021 00:34:15 +0200 Subject: [PATCH] add url setting --- InvenTree/InvenTree/urls.py | 10 ++++++---- InvenTree/common/models.py | 7 ++++++- InvenTree/templates/InvenTree/settings/plugin.html | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 1b92757fda..2ed421d2ac 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -43,6 +43,7 @@ from .views import AppearanceSelectView, SettingCategorySelectView from .views import DynamicJsView from common.views import SettingEdit, UserSettingEdit +from common.models import InvenTreeSetting from .api import InfoView, NotFoundView from .api import ActionPluginView @@ -125,11 +126,12 @@ translated_javascript_urls = [ ] # Integration plugin urls -integration_plugins = settings.INTEGRATION_PLUGINS interation_urls = [] -for plugin in integration_plugins: - if plugin.mixin_enabled('urls'): - interation_urls.append(plugin.urlpatterns) +if InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'): + integration_plugins = settings.INTEGRATION_PLUGINS + for plugin in integration_plugins: + if plugin.mixin_enabled('urls'): + interation_urls.append(plugin.urlpatterns) urlpatterns = [ url(r'^part/', include(part_urls)), diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 848e4e9b0a..8bdc48bbb1 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -854,7 +854,12 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'default': '', 'choices': settings_group_options }, - + 'ENABLE_PLUGINS_URL': { + 'name': _('Enable URL integration'), + 'description': _('Enable plugins to add URL routes'), + 'default': False, + 'validator': bool, + }, 'ENABLE_PLUGINS_NAVIGATION': { 'name': _('Enable navigation integration'), 'description': _('Enable plugins to integrate into navigation'), diff --git a/InvenTree/templates/InvenTree/settings/plugin.html b/InvenTree/templates/InvenTree/settings/plugin.html index 8b4f03bbea..19ab02761a 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -16,6 +16,7 @@ {% include "InvenTree/settings/header.html" %} + {% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_URL" %} {% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_NAVIGATION" %}