Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CSV export #2452

Merged
merged 4 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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)
* Privacy Request approval now uses a modal [#2443](https://github.com/ethyca/fides/pull/2443)

### Developer Experience
Expand Down
24 changes: 14 additions & 10 deletions src/fides/api/ops/api/v1/endpoints/privacy_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,14 @@ def privacy_request_csv_download(

csv_file.writerow(
[
"Time received",
"Subject identity",
"Policy key",
"Request status",
"Reviewer",
"Time approved/denied",
"Denial reason",
"Status",
"Request Type",
"Subject Identity",
"Time Received",
"Reviewed By",
"Request ID",
"Time Approved/Denied",
"Denial Reason",
TheAndrewJackson marked this conversation as resolved.
Show resolved Hide resolved
]
)
privacy_request_ids: List[str] = [r.id for r in privacy_request_query]
Expand All @@ -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[
Expand Down
15 changes: 8 additions & 7 deletions tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,17 +1280,18 @@ 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,
"ga_client_id": None,
}
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)

Expand Down