From 841f6e086ae7ac2c5dee077c2e32854bf39ab01d Mon Sep 17 00:00:00 2001 From: James Person Date: Wed, 31 Jul 2024 10:25:11 -0400 Subject: [PATCH] Add a Log When Creating a UEI Validation Waiver (#4123) * Log UEI validation waivers on addition by admin * Fix a typo in a comment --- backend/api/test_serializers.py | 2 +- backend/audit/admin.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/api/test_serializers.py b/backend/api/test_serializers.py index 489ef933f0..c94de7972f 100644 --- a/backend/api/test_serializers.py +++ b/backend/api/test_serializers.py @@ -125,7 +125,7 @@ def test_expired_waived_uei_payload(self): expiration=expired["expiration"], ) - # Invalid due to the waiver being expired. Mock the SAM call as though the entity doesnt exist. + # Invalid due to the waiver being expired. Mock the SAM call as though the entity does not exist. with patch("api.uei.SESSION.get") as mock_get: mock_get.return_value.status_code = 200 mock_get.return_value.json.return_value = json.loads(missing_uei_results) diff --git a/backend/audit/admin.py b/backend/audit/admin.py index 50494c1521..9f7bd16e74 100644 --- a/backend/audit/admin.py +++ b/backend/audit/admin.py @@ -262,6 +262,12 @@ class UeiValidationWaiverAdmin(admin.ModelAdmin): ) readonly_fields = ("timestamp",) + def save_model(self, request, obj, form, change): + super().save_model(request, obj, form, change) + logger.info( + f'Validation Waiver for UEI "{obj.uei}" successfully added by user: {request.user.email}.' + ) + admin.site.register(Access, AccessAdmin) admin.site.register(DeletedAccess, DeletedAccessAdmin)