From 1c93a126ae20bfb6e77acf6fd471811702c611fe Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 19 Oct 2021 21:39:58 +0200 Subject: [PATCH] Revert "remove url load setting for plugin" This reverts commit e37477eb156f243a0ca1c321c80c82f59735fef8. --- InvenTree/InvenTree/urls.py | 13 ++++++++++--- InvenTree/common/models.py | 6 ++++++ InvenTree/templates/InvenTree/settings/plugin.html | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index d21f7b49c3..e181d130fa 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 @@ -126,9 +127,15 @@ translated_javascript_urls = [ # Integration plugin urls interation_urls = [] -for plugin in settings.INTEGRATION_PLUGINS.values(): - if plugin.mixin_enabled('urls'): - interation_urls.append(plugin.urlpatterns) +plugin_url_enabled = False +try: + plugin_url_enabled = InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL') +except Exception as _e: + print(_e) +if settings.TESTING or plugin_url_enabled: + for plugin in settings.INTEGRATION_PLUGINS.values(): + 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 3e2f787457..630a8d03da 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -875,6 +875,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 a7f63a65ef..acacbdff4d 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -19,6 +19,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" %} {% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_SETTING"%} {% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_APP"%}