From 2638ef046dffc57622401a53fa2139649c839784 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 13 Nov 2021 01:39:22 +0100 Subject: [PATCH] own flag to enable plugin testing --- InvenTree/InvenTree/settings.py | 1 + InvenTree/InvenTree/urls.py | 2 +- InvenTree/plugin/apps.py | 6 +++--- InvenTree/plugin/templatetags/plugin_extras.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index a2b1de5527..6c6008a029 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -55,6 +55,7 @@ def get_setting(environment_var, backup_val, default_value=None): # Determine if we are running in "test" mode e.g. "manage.py test" TESTING = 'test' in sys.argv +PLUGIN_TESTING = TESTING # used to forece enable everything plugin # New requirement for django 3.2+ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 0f7f555073..0a758e5a32 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -125,7 +125,7 @@ translated_javascript_urls = [ # Integration plugin urls interation_urls = [] try: - if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'): + if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'): for plugin in settings.INTEGRATION_PLUGINS.values(): if plugin.mixin_enabled('urls'): interation_urls.append(plugin.urlpatterns) diff --git a/InvenTree/plugin/apps.py b/InvenTree/plugin/apps.py index 8d43d09354..932ed22027 100644 --- a/InvenTree/plugin/apps.py +++ b/InvenTree/plugin/apps.py @@ -69,7 +69,7 @@ class PluginAppConfig(AppConfig): plugin_db_setting, _ = PluginConfig.objects.get_or_create(key=plug_key, name=plug_name) # always activate if testing - if settings.TESTING or plugin_db_setting.active: + if settings.PLUGIN_TESTING or plugin_db_setting.active: # init package # now we can be sure that an admin has activated the plugin -> as of Nov 2021 there are not many checks in place # but we could enhance those to check signatures, run the plugin against a whitelist etc. @@ -100,7 +100,7 @@ class PluginAppConfig(AppConfig): def activate_integration_settings(self, plugins): from common.models import InvenTreeSetting - if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'): + if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'): logger.info('Registering IntegrationPlugin settings') for slug, plugin in plugins: if plugin.mixin_enabled('settings'): @@ -113,7 +113,7 @@ class PluginAppConfig(AppConfig): def activate_integration_app(self, plugins): from common.models import InvenTreeSetting - if settings.TESTING or ((not settings.INTEGRATION_APPS_LOADED) and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')): + if settings.PLUGIN_TESTING or ((not settings.INTEGRATION_APPS_LOADED) and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')): logger.info('Registering IntegrationPlugin apps') settings.INTEGRATION_APPS_LOADED = True # ensure this section will not run again apps_changed = False diff --git a/InvenTree/plugin/templatetags/plugin_extras.py b/InvenTree/plugin/templatetags/plugin_extras.py index 56d50fab01..44a1c292ed 100644 --- a/InvenTree/plugin/templatetags/plugin_extras.py +++ b/InvenTree/plugin/templatetags/plugin_extras.py @@ -39,7 +39,7 @@ def mixin_enabled(plugin, key, *args, **kwargs): @register.simple_tag() def navigation_enabled(*args, **kwargs): """Return if plugin navigation is enabled""" - if djangosettings.TESTING: + if djangosettings.PLUGIN_TESTING: return True return InvenTreeSetting.get_setting('ENABLE_PLUGINS_NAVIGATION')