mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	BUG: Fix settings lookup (#4147)
* Load plugin settings also from env [BUG ]PLUGIN setting only work when set in config file Fixes #4146 * formatting fix * use 'INVENTREE_' prefix everyhwere for envs * make more settings 'env'-able
This commit is contained in:
		@@ -238,7 +238,7 @@ AUTHENTICATION_BACKENDS = CONFIG.get('authentication_backends', [
 | 
				
			|||||||
    'allauth.account.auth_backends.AuthenticationBackend',      # SSO login via external providers
 | 
					    'allauth.account.auth_backends.AuthenticationBackend',      # SSO login via external providers
 | 
				
			||||||
])
 | 
					])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEBUG_TOOLBAR_ENABLED = DEBUG and CONFIG.get('debug_toolbar', False)
 | 
					DEBUG_TOOLBAR_ENABLED = DEBUG and get_setting('INVENTREE_DEBUG_TOOLBAR', 'debug_toolbar', False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# If the debug toolbar is enabled, add the modules
 | 
					# If the debug toolbar is enabled, add the modules
 | 
				
			||||||
if DEBUG_TOOLBAR_ENABLED:  # pragma: no cover
 | 
					if DEBUG_TOOLBAR_ENABLED:  # pragma: no cover
 | 
				
			||||||
@@ -626,7 +626,7 @@ AUTH_PASSWORD_VALIDATORS = [
 | 
				
			|||||||
# Extra (optional) URL validators
 | 
					# Extra (optional) URL validators
 | 
				
			||||||
# See https://docs.djangoproject.com/en/2.2/ref/validators/#django.core.validators.URLValidator
 | 
					# See https://docs.djangoproject.com/en/2.2/ref/validators/#django.core.validators.URLValidator
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXTRA_URL_SCHEMES = CONFIG.get('extra_url_schemes', [])
 | 
					EXTRA_URL_SCHEMES = get_setting('INVENTREE_EXTRA_URL_SCHEMES', 'extra_url_schemes', [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if type(EXTRA_URL_SCHEMES) not in [list]:  # pragma: no cover
 | 
					if type(EXTRA_URL_SCHEMES) not in [list]:  # pragma: no cover
 | 
				
			||||||
    logger.warning("extra_url_schemes not correctly formatted")
 | 
					    logger.warning("extra_url_schemes not correctly formatted")
 | 
				
			||||||
@@ -688,12 +688,9 @@ if get_boolean_setting('TEST_TRANSLATIONS', default_value=False):  # pragma: no
 | 
				
			|||||||
    django.conf.locale.LANG_INFO = LANG_INFO
 | 
					    django.conf.locale.LANG_INFO = LANG_INFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Currencies available for use
 | 
					# Currencies available for use
 | 
				
			||||||
CURRENCIES = CONFIG.get(
 | 
					CURRENCIES = get_setting('INVENTREE_CURRENCIES', 'currencies', [
 | 
				
			||||||
    'currencies',
 | 
					 | 
				
			||||||
    [
 | 
					 | 
				
			||||||
    'AUD', 'CAD', 'CNY', 'EUR', 'GBP', 'JPY', 'NZD', 'USD',
 | 
					    'AUD', 'CAD', 'CNY', 'EUR', 'GBP', 'JPY', 'NZD', 'USD',
 | 
				
			||||||
    ],
 | 
					])
 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Maximum number of decimal places for currency rendering
 | 
					# Maximum number of decimal places for currency rendering
 | 
				
			||||||
CURRENCY_DECIMAL_PLACES = 6
 | 
					CURRENCY_DECIMAL_PLACES = 6
 | 
				
			||||||
@@ -750,12 +747,12 @@ IMPORT_EXPORT_USE_TRANSACTIONS = True
 | 
				
			|||||||
SITE_ID = 1
 | 
					SITE_ID = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Load the allauth social backends
 | 
					# Load the allauth social backends
 | 
				
			||||||
SOCIAL_BACKENDS = CONFIG.get('social_backends', [])
 | 
					SOCIAL_BACKENDS = get_setting('INVENTREE_SOCIAL_BACKENDS', 'social_backends', [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for app in SOCIAL_BACKENDS:
 | 
					for app in SOCIAL_BACKENDS:
 | 
				
			||||||
    INSTALLED_APPS.append(app)  # pragma: no cover
 | 
					    INSTALLED_APPS.append(app)  # pragma: no cover
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOCIALACCOUNT_PROVIDERS = CONFIG.get('social_providers', None)
 | 
					SOCIALACCOUNT_PROVIDERS = get_setting('INVENTREE_SOCIAL_PROVIDERS', 'social_providers', None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if SOCIALACCOUNT_PROVIDERS is None:
 | 
					if SOCIALACCOUNT_PROVIDERS is None:
 | 
				
			||||||
    SOCIALACCOUNT_PROVIDERS = {}
 | 
					    SOCIALACCOUNT_PROVIDERS = {}
 | 
				
			||||||
@@ -865,10 +862,10 @@ PLUGINS_ENABLED = get_boolean_setting('INVENTREE_PLUGINS_ENABLED', 'plugins_enab
 | 
				
			|||||||
PLUGIN_FILE = config.get_plugin_file()
 | 
					PLUGIN_FILE = config.get_plugin_file()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Plugin test settings
 | 
					# Plugin test settings
 | 
				
			||||||
PLUGIN_TESTING = CONFIG.get('PLUGIN_TESTING', TESTING)  # are plugins beeing tested?
 | 
					PLUGIN_TESTING = get_setting('INVENTREE_PLUGIN_TESTING', 'PLUGIN_TESTING', TESTING)                     # Are plugins beeing tested?
 | 
				
			||||||
PLUGIN_TESTING_SETUP = CONFIG.get('PLUGIN_TESTING_SETUP', False)  # load plugins from setup hooks in testing?
 | 
					PLUGIN_TESTING_SETUP = get_setting('INVENTREE_PLUGIN_TESTING_SETUP', 'PLUGIN_TESTING_SETUP', False)     # Load plugins from setup hooks in testing?
 | 
				
			||||||
PLUGIN_TESTING_EVENTS = False                                                                           # Flag if events are tested right now
 | 
					PLUGIN_TESTING_EVENTS = False                                                                           # Flag if events are tested right now
 | 
				
			||||||
PLUGIN_RETRY = CONFIG.get('PLUGIN_RETRY', 5)  # how often should plugin loading be tried?
 | 
					PLUGIN_RETRY = get_setting('INVENTREE_PLUGIN_RETRY', 'PLUGIN_RETRY', 5)                                 # How often should plugin loading be tried?
 | 
				
			||||||
PLUGIN_FILE_CHECKED = False                                                                             # Was the plugin file checked?
 | 
					PLUGIN_FILE_CHECKED = False                                                                             # Was the plugin file checked?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# User interface customization values
 | 
					# User interface customization values
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user