From 988d263ef16090e2e81b2caada5189469aa6eafb Mon Sep 17 00:00:00 2001 From: Ben Charlton Date: Mon, 24 Aug 2020 15:05:21 +0100 Subject: [PATCH 1/3] Allow custom authentication / middleware in config.yaml --- InvenTree/InvenTree/settings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index d3a5ee919d..24ba9278c8 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -163,7 +163,7 @@ LOGGING = { }, } -MIDDLEWARE = [ +MIDDLEWARE = CONFIG.get('middleware', [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -173,9 +173,12 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'InvenTree.middleware.AuthRequiredMiddleware' -] +]) + +AUTHENTICATION_BACKENDS = CONFIG.get('authentication_backends', [ + 'django.contrib.auth.backends.ModelBackend' +]) # If the debug toolbar is enabled, add the modules if DEBUG and CONFIG.get('debug_toolbar', False): From b6f9590d5593717938c3fcaa81326a9259bae981 Mon Sep 17 00:00:00 2001 From: Ben Charlton Date: Mon, 24 Aug 2020 15:24:18 +0100 Subject: [PATCH 2/3] Add default config example to config template --- InvenTree/config_template.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index 1c776a6f7a..0a60e205a1 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -86,4 +86,21 @@ latex: enabled: False interpreter: pdflatex # Extra options to pass through to the LaTeX interpreter - options: '' \ No newline at end of file + options: '' + +# Permit custom authentication backends +#authentication_backends: +# - 'django.contrib.auth.backends.ModelBackend' + +# Custom middleware, sometimes needed alongside an authentication backend change. +#middleware: +# - 'django.middleware.security.SecurityMiddleware' +# - 'django.contrib.sessions.middleware.SessionMiddleware' +# - 'django.middleware.locale.LocaleMiddleware' +# - 'django.middleware.common.CommonMiddleware' +# - 'django.middleware.csrf.CsrfViewMiddleware' +# - 'corsheaders.middleware.CorsMiddleware' +# - 'django.contrib.auth.middleware.AuthenticationMiddleware' +# - 'django.contrib.messages.middleware.MessageMiddleware' +# - 'django.middleware.clickjacking.XFrameOptionsMiddleware' +# - 'InvenTree.middleware.AuthRequiredMiddleware' \ No newline at end of file From 9149aa1536b5ef4a03ea7641a5971164932402ef Mon Sep 17 00:00:00 2001 From: Ben Charlton Date: Mon, 24 Aug 2020 18:04:22 +0100 Subject: [PATCH 3/3] Fix internal server error when serializing stock with no location --- InvenTree/stock/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index faad9db324..4b62e9903d 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -1120,7 +1120,8 @@ class StockItemSerialize(AjaxUpdateView): initials['quantity'] = item.quantity initials['serial_numbers'] = item.part.getSerialNumberString(item.quantity) - initials['destination'] = item.location.pk + if item.location is not None: + initials['destination'] = item.location.pk return initials