From 9abbb6cb5e0b1510fd8305ea1bb90ce7aa6d0037 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 19 Nov 2021 21:50:41 +0100 Subject: [PATCH 1/2] PEP fixes for ci / maintenance scripts --- ci/check_js_templates.py | 4 +++- ci/check_locale_files.py | 4 ++-- ci/check_version_number.py | 5 ++--- tasks.py | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ci/check_js_templates.py b/ci/check_js_templates.py index e3c1f0148f..b9db7fe612 100644 --- a/ci/check_js_templates.py +++ b/ci/check_js_templates.py @@ -28,6 +28,7 @@ print("=================================") print("Checking static javascript files:") print("=================================") + def check_invalid_tag(data): pattern = r"{%(\w+)" @@ -45,6 +46,7 @@ def check_invalid_tag(data): return err_count + def check_prohibited_tags(data): allowed_tags = [ @@ -78,7 +80,7 @@ def check_prohibited_tags(data): has_trans = True if not has_trans: - print(f" > file is missing 'trans' tags") + print(" > file is missing 'trans' tags") err_count += 1 return err_count diff --git a/ci/check_locale_files.py b/ci/check_locale_files.py index 9995ceaec5..a4300a6cbb 100644 --- a/ci/check_locale_files.py +++ b/ci/check_locale_files.py @@ -24,7 +24,7 @@ for line in str(out.decode()).split('\n'): if len(locales) > 0: print("There are {n} unstaged locale files:".format(n=len(locales))) - for l in locales: - print(" - {l}".format(l=l)) + for lang in locales: + print(" - {l}".format(l=lang)) sys.exit(len(locales)) \ No newline at end of file diff --git a/ci/check_version_number.py b/ci/check_version_number.py index a338798a0c..258c8780d8 100644 --- a/ci/check_version_number.py +++ b/ci/check_version_number.py @@ -9,7 +9,6 @@ import sys import re import os import argparse -import requests if __name__ == '__main__': @@ -65,7 +64,7 @@ if __name__ == '__main__': e.g. "0.5 dev" """ - print(f"Checking development branch") + print("Checking development branch") pattern = "^\d+(\.\d+)+ dev$" @@ -81,7 +80,7 @@ if __name__ == '__main__': e.g. "0.5.1" """ - print(f"Checking release branch") + print("Checking release branch") pattern = "^\d+(\.\d+)+$" diff --git a/tasks.py b/tasks.py index c960fb8657..b33af84384 100644 --- a/tasks.py +++ b/tasks.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from shutil import copyfile import os import json import sys @@ -134,6 +133,7 @@ def rebuild_models(c): manage(c, "rebuild_models", pty=True) + @task def rebuild_thumbnails(c): """ @@ -142,6 +142,7 @@ def rebuild_thumbnails(c): manage(c, "rebuild_thumbnails", pty=True) + @task def clean_settings(c): """ @@ -150,6 +151,7 @@ def clean_settings(c): manage(c, "clean_settings") + @task(post=[rebuild_models, rebuild_thumbnails]) def migrate(c): """ @@ -306,7 +308,7 @@ def export_records(c, filename='data.json'): # Get an absolute path to the file if not os.path.isabs(filename): filename = os.path.join(localDir(), filename) - filename = os.path.abspath(filename) + filename = os.path.abspath(filename) print(f"Exporting database records to file '{filename}'") From 512c73a59e51717bc8374dd25c5d7fafe774ed1e Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 19 Nov 2021 21:51:57 +0100 Subject: [PATCH 2/2] make diffs for extending middleware cleaner --- InvenTree/InvenTree/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 0f60d4dbf0..cc752189b5 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -306,7 +306,7 @@ MIDDLEWARE = CONFIG.get('middleware', [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'InvenTree.middleware.AuthRequiredMiddleware' + 'InvenTree.middleware.AuthRequiredMiddleware', ]) # Error reporting middleware