From b7ad52e46de60096f551fc15a3269eb5c8c77390 Mon Sep 17 00:00:00 2001 From: Alex Steel <130377221+asteel-gsa@users.noreply.github.com> Date: Fri, 28 Mar 2025 13:39:59 -0400 Subject: [PATCH 1/4] Bump Django --- backend/dev-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/dev-requirements.txt b/backend/dev-requirements.txt index c2be0783c8..7e6a233bf2 100644 --- a/backend/dev-requirements.txt +++ b/backend/dev-requirements.txt @@ -120,9 +120,9 @@ coverage==7.6.3 \ cssbeautifier==1.15.1 \ --hash=sha256:9f7064362aedd559c55eeecf6b6bed65e05f33488dcbe39044f0403c26e1c006 # via djlint -django==5.1.2 \ - --hash=sha256:bd7376f90c99f96b643722eee676498706c9fd7dc759f55ebfaf2c08ebcdf4f0 \ - --hash=sha256:f11aa87ad8d5617171e3f77e1d5d16f004b79a2cf5d2e1d2b97a6a1f8e9ba5ed +django==5.1.7 \ + --hash=sha256:1323617cb624add820cb9611cdcc788312d250824f92ca6048fda8625514af2b \ + --hash=sha256:30de4ee43a98e5d3da36a9002f287ff400b43ca51791920bfb35f6917bfe041c # via # -c ./requirements/../requirements.txt # django-debug-toolbar From ce7f1fa07135026365b6aa6fb8054db805399767 Mon Sep 17 00:00:00 2001 From: Bobby Novak <176936850+rnovak338@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:33:30 -0400 Subject: [PATCH 2/4] Validate JSON exists in LogEntry message As of django's new version `5.1.7`, this field `instance.change_message` is not equipped to handle a case where it is null. --- backend/support/admin.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/backend/support/admin.py b/backend/support/admin.py index be84b5731f..2694f35bf6 100644 --- a/backend/support/admin.py +++ b/backend/support/admin.py @@ -190,22 +190,23 @@ def add_custom_field_to_log(sender, instance, created, **kwargs): obj = qset.first() # update content of record after save occurred. - change_message_json = json.loads(instance.change_message) - - if change_message_json: - if model_class == UserPermission: - change_message_json[0]["content"] = list( - qset.values("email", "permission__slug") - ) - elif model_class == TribalApiAccessKeyIds: - change_message_json[0]["content"] = list(qset.values("email", "key_id")) - else: - change_message_json[0]["content"] = list(qset.values("id")) + if instance.change_message: + change_message_json = json.loads(instance.change_message) + + if change_message_json: + if model_class == UserPermission: + change_message_json[0]["content"] = list( + qset.values("email", "permission__slug") + ) + elif model_class == TribalApiAccessKeyIds: + change_message_json[0]["content"] = list(qset.values("email", "key_id")) + else: + change_message_json[0]["content"] = list(qset.values("id")) - # record still exists. - if obj: - change_message_json[0]["id"] = obj.pk + # record still exists. + if obj: + change_message_json[0]["id"] = obj.pk - # write changes to instance. - instance.change_message = json.dumps(change_message_json, cls=DateEncoder) - instance.save() + # write changes to instance. + instance.change_message = json.dumps(change_message_json, cls=DateEncoder) + instance.save() From b0b9e5d9a30e6b506fbdca22b72ba96df6027280 Mon Sep 17 00:00:00 2001 From: Bobby Novak <176936850+rnovak338@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:42:48 -0400 Subject: [PATCH 3/4] Linting --- backend/support/admin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/support/admin.py b/backend/support/admin.py index 2694f35bf6..d08166a900 100644 --- a/backend/support/admin.py +++ b/backend/support/admin.py @@ -199,7 +199,9 @@ def add_custom_field_to_log(sender, instance, created, **kwargs): qset.values("email", "permission__slug") ) elif model_class == TribalApiAccessKeyIds: - change_message_json[0]["content"] = list(qset.values("email", "key_id")) + change_message_json[0]["content"] = list( + qset.values("email", "key_id") + ) else: change_message_json[0]["content"] = list(qset.values("id")) From 1a21af27f707be34bba69785ec1c42220db08664 Mon Sep 17 00:00:00 2001 From: Alex Steel <130377221+asteel-gsa@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:57:41 -0400 Subject: [PATCH 4/4] Update Makefile --- backend/Makefile | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/backend/Makefile b/backend/Makefile index 72dd96ba16..ae695f9bd7 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -1,23 +1,18 @@ +# Generate an updated requirements.txt +# We want these to run at the same time if we are ever updating a package in either file +# since the dev-requirements.txt are built on top of the requirements.txt +compile: + @pip-compile --generate-hashes ./requirements/requirements.in -o requirements.txt --allow-unsafe + @pip-compile --generate-hashes ./requirements/dev-requirements.in -o dev-requirements.txt --allow-unsafe + # Install python dependencies install: @pip install -r requirements.txt @npm ci -# Generate an updated requirements.txt -compile: - @touch requirements.txt - @rm requirements.txt - @pip-compile --generate-hashes ./requirements/requirements.in -o requirements.txt --allow-unsafe - compile-assets: @node build-assets.mjs -# Generate an updated dev-requirements.txt -compile-dev: - @touch dev-requirements.txt - @rm dev-requirements.txt - @pip-compile --generate-hashes ./requirements/dev-requirements.in -o dev-requirements.txt --allow-unsafe - # Install python dev dependencies install-dev: @pip install -r dev-requirements.txt