From b1273d70871e3d7e891e8f9e134244e9ac067a8a Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 31 Jan 2023 14:39:08 -0500 Subject: [PATCH 1/3] Update CSV export --- .../v1/endpoints/privacy_request_endpoints.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py b/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py index c68499ad0c5..3190459b0a5 100644 --- a/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py +++ b/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py @@ -254,13 +254,14 @@ def privacy_request_csv_download( csv_file.writerow( [ + "Status", + "Request Type", + "Subject Identity", "Time received", - "Subject identity", - "Policy key", - "Request status", - "Reviewer", - "Time approved/denied", - "Denial reason", + "Reviewed By", + "Request ID", + "Time Approved/Denied", + "Denial Reason", ] ) privacy_request_ids: List[str] = [r.id for r in privacy_request_query] @@ -278,17 +279,20 @@ def privacy_request_csv_download( if pr.status == PrivacyRequestStatus.denied and pr.id in denial_audit_logs else None ) + csv_file.writerow( [ - pr.created_at, - pr.get_persisted_identity().dict(), - pr.policy.key if pr.policy else None, pr.status.value if pr.status else None, + pr.policy.rules[0].action_type if len(pr.policy.rules) > 0 else None, + pr.get_persisted_identity().dict(), + pr.created_at, pr.reviewed_by, + pr.id, pr.reviewed_at, denial_reason, ] ) + f.seek(0) response = StreamingResponse(f, media_type="text/csv") response.headers[ From 15243ada6124b4044781fafa4ea8fe797dcd2576 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 31 Jan 2023 15:10:45 -0500 Subject: [PATCH 2/3] Update CSV test --- .../api/v1/endpoints/privacy_request_endpoints.py | 2 +- .../endpoints/test_privacy_request_endpoints.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py b/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py index 3190459b0a5..7bb01c27c0c 100644 --- a/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py +++ b/src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py @@ -257,7 +257,7 @@ def privacy_request_csv_download( "Status", "Request Type", "Subject Identity", - "Time received", + "Time Received", "Reviewed By", "Request ID", "Time Approved/Denied", diff --git a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py index d7eae67e2d7..a7ab0e8d512 100644 --- a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py @@ -1280,16 +1280,17 @@ def test_get_privacy_requests_csv_format( csv_file = csv.DictReader(file, delimiter=",") first_row = next(csv_file) - assert parse(first_row["Time received"], ignoretz=True) == created_at - assert ast.literal_eval(first_row["Subject identity"]) == { + assert parse(first_row["Time Received"], ignoretz=True) == created_at + assert ast.literal_eval(first_row["Subject Identity"]) == { "email": TEST_EMAIL, "phone_number": TEST_PHONE, } - assert first_row["Policy key"] == "example_access_request_policy" - assert first_row["Request status"] == "approved" - assert first_row["Reviewer"] == user.id - assert parse(first_row["Time approved/denied"], ignoretz=True) == reviewed_at - assert first_row["Denial reason"] == "" + assert first_row["Request Type"] == "access" + assert first_row["Status"] == "approved" + assert first_row["Reviewed By"] == user.id + assert parse(first_row["Time Approved/Denied"], ignoretz=True) == reviewed_at + assert first_row["Denial Reason"] == "" + assert first_row["Request ID"] == privacy_request.id privacy_request.delete(db) From 960a9b1fa3dfd549ce3f805d3e4c8c09ac35c617 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 31 Jan 2023 15:11:37 -0500 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bfef24f752..cf683fa3719 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The types of changes are: * Display the request type instead of the policy name on the request table [#2382](https://github.com/ethyca/fides/pull/2382) * Make denial reasons required [#2400](https://github.com/ethyca/fides/pull/2400) * Display the policy key on the request details page [#2395](https://github.com/ethyca/fides/pull/2395) +* Updated CSV export [#2452](https://github.com/ethyca/fides/pull/2452) ### Developer Experience