From 88c173b12cc38e97658dd20d353a24d6aaaf2cc5 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 11:07:05 -0500 Subject: [PATCH 1/8] strip forward slash --- history/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history/conf.py b/history/conf.py index 2f64a2f..c5a8691 100644 --- a/history/conf.py +++ b/history/conf.py @@ -33,5 +33,5 @@ # A list of path prefixes the history middleware should ignore. MIDDLEWARE_IGNORE = getattr( - settings, "HISTORY_MIDDLEWARE_IGNORE", [settings.STATIC_URL, settings.MEDIA_URL] + settings, "HISTORY_MIDDLEWARE_IGNORE", [settings.STATIC_URL.lstrip('/'), settings.MEDIA_URL.lstrip('/')] ) From a0c58f9b77eabcd67946a8c29b60b3389e210d60 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 11:10:05 -0500 Subject: [PATCH 2/8] run black --- history/conf.py | 4 +++- history/management/commands/triggers.py | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/history/conf.py b/history/conf.py index c5a8691..72357be 100644 --- a/history/conf.py +++ b/history/conf.py @@ -33,5 +33,7 @@ # A list of path prefixes the history middleware should ignore. MIDDLEWARE_IGNORE = getattr( - settings, "HISTORY_MIDDLEWARE_IGNORE", [settings.STATIC_URL.lstrip('/'), settings.MEDIA_URL.lstrip('/')] + settings, + "HISTORY_MIDDLEWARE_IGNORE", + [settings.STATIC_URL.lstrip("/"), settings.MEDIA_URL.lstrip("/")], ) diff --git a/history/management/commands/triggers.py b/history/management/commands/triggers.py index 8ebb53d..dcf1679 100644 --- a/history/management/commands/triggers.py +++ b/history/management/commands/triggers.py @@ -223,9 +223,9 @@ def create_history_table(cursor, base_table, pk_name, pk_type): "schema": conf.SCHEMA_NAME, "table": history_table, "role": conf.DB_ROLE, - "timestamp_type": "timestamp with time zone" - if conf.USE_TIMEZONES - else "timestamp", + "timestamp_type": ( + "timestamp with time zone" if conf.USE_TIMEZONES else "timestamp" + ), "pk_name": pk_name, "pk_type": pk_type, "user_field": conf.USER_FIELD, @@ -450,9 +450,9 @@ def create_trigger(cursor, trigger_type, table_name, pk_name, table_schema="publ "history_user_field": conf.USER_FIELD, "return": "OLD" if trigger_type == "delete" else "NEW", "role": conf.DB_ROLE, - "timestamp_type": "timestamp with time zone" - if conf.USE_TIMEZONES - else "timestamp", + "timestamp_type": ( + "timestamp with time zone" if conf.USE_TIMEZONES else "timestamp" + ), "user_type": conf.USER_TYPE, "default_user": maybe_quote(conf.DEFAULT_USER), "default_user_error": "true" if conf.DEFAULT_USER_ERROR else "false", From 074d2b99348a27d4c9bafcccf77d2f1c2db0b987 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 11:11:49 -0500 Subject: [PATCH 3/8] flake8 --- history/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history/admin.py b/history/admin.py index 74da7dd..3be6514 100644 --- a/history/admin.py +++ b/history/admin.py @@ -47,7 +47,7 @@ def show_history(self, request, queryset, extra_context=None): **self.admin_site.each_context(request), "use_json": USE_JSON, "history": object_history, - "title": f"{ model_class.__name__ } History", + "title": f"{model_class.__name__} History", "opts": model_class._meta, "queryset": queryset, **(extra_context or {}), From 0b8350076c3a5f692e482f75d222df80785cfa98 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 14:10:32 -0500 Subject: [PATCH 4/8] Update implementation to just skip forward slash prefix --- history/conf.py | 2 +- history/middleware.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/history/conf.py b/history/conf.py index 72357be..9e907a8 100644 --- a/history/conf.py +++ b/history/conf.py @@ -35,5 +35,5 @@ MIDDLEWARE_IGNORE = getattr( settings, "HISTORY_MIDDLEWARE_IGNORE", - [settings.STATIC_URL.lstrip("/"), settings.MEDIA_URL.lstrip("/")], + [settings.STATIC_URL, settings.MEDIA_URL], ) diff --git a/history/middleware.py b/history/middleware.py index 88d77e2..a51fe88 100644 --- a/history/middleware.py +++ b/history/middleware.py @@ -22,7 +22,7 @@ def __init__(self, get_response=None): def __call__(self, request): create_history = True for prefix in conf.MIDDLEWARE_IGNORE: - if prefix and request.path.startswith(prefix): + if prefix and prefix != '/' and request.path.startswith(prefix): create_history = False if create_history: From 2e31536f26d4353ecc8a601a9130bbeccb598c11 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 14:17:39 -0500 Subject: [PATCH 5/8] run black --- history/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history/middleware.py b/history/middleware.py index a51fe88..b1d744a 100644 --- a/history/middleware.py +++ b/history/middleware.py @@ -22,7 +22,7 @@ def __init__(self, get_response=None): def __call__(self, request): create_history = True for prefix in conf.MIDDLEWARE_IGNORE: - if prefix and prefix != '/' and request.path.startswith(prefix): + if prefix and prefix != "/" and request.path.startswith(prefix): create_history = False if create_history: From e0acf5d9570d0f64139bacadd3405ca0535c087b Mon Sep 17 00:00:00 2001 From: Brad Rutten Date: Mon, 4 Mar 2024 14:21:09 -0500 Subject: [PATCH 6/8] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d9994d..2c7cb4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: - 5432:5432 strategy: matrix: - django-version: [2.2, 3.1, 3.2] - python-version: [3.6, 3.7, 3.8, 3.9] + django-version: [2.2, 3.1, 3.2, 4.2] + python-version: [3.7, 3.8, 3.9, 3.11] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 263cdd675619d2e634cdc1f1aab96bd53ff9f9dd Mon Sep 17 00:00:00 2001 From: Brad Rutten Date: Mon, 4 Mar 2024 14:24:39 -0500 Subject: [PATCH 7/8] Update ci.yml part 2 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c7cb4b..c6ff937 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: - 5432:5432 strategy: matrix: - django-version: [2.2, 3.1, 3.2, 4.2] - python-version: [3.7, 3.8, 3.9, 3.11] + django-version: [3.2, 4.2] + python-version: [3.8, 3.9, 3.11] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 746318cb2db668bef94f3bbd0719730d5f07ca60 Mon Sep 17 00:00:00 2001 From: ruttenb Date: Mon, 4 Mar 2024 14:26:39 -0500 Subject: [PATCH 8/8] Bump version --- history/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history/__init__.py b/history/__init__.py index 529a615..dbbd49f 100644 --- a/history/__init__.py +++ b/history/__init__.py @@ -1,4 +1,4 @@ -__version_info__ = (2, 0, 1) +__version_info__ = (2, 0, 2) __version__ = ".".join(str(i) for i in __version_info__) default_app_config = "history.apps.HistoryConfig"