mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
notify-api-771 fix columns in reports
This commit is contained in:
@@ -78,21 +78,21 @@ def generate_notifications_csv(**kwargs):
|
||||
template=get_sample_template(kwargs["template_type"]),
|
||||
)
|
||||
original_column_headers = original_upload.column_headers
|
||||
fieldnames = (
|
||||
["Row number"]
|
||||
+ original_column_headers
|
||||
+ [
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
"Job",
|
||||
"Carrier",
|
||||
"Carrier Response",
|
||||
"Status",
|
||||
"Time",
|
||||
]
|
||||
)
|
||||
fieldnames = [
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
"Job",
|
||||
"Carrier",
|
||||
"Carrier Response",
|
||||
"Status",
|
||||
"Time",
|
||||
]
|
||||
for header in original_column_headers:
|
||||
fieldnames.append(header)
|
||||
|
||||
else:
|
||||
# TODO This is deprecated because everything should be a job now, is it ever invoked?
|
||||
fieldnames = [
|
||||
"Recipient",
|
||||
"Template",
|
||||
@@ -104,6 +104,7 @@ def generate_notifications_csv(**kwargs):
|
||||
"Status",
|
||||
"Time",
|
||||
]
|
||||
current_app.logger.warning("Invoking deprecated report format")
|
||||
|
||||
yield ",".join(fieldnames) + "\n"
|
||||
|
||||
@@ -118,26 +119,23 @@ def generate_notifications_csv(**kwargs):
|
||||
|
||||
current_app.logger.info(f"\n\n{notification}")
|
||||
if kwargs.get("job_id"):
|
||||
values = (
|
||||
[
|
||||
notification["row_number"],
|
||||
]
|
||||
+ [
|
||||
values = [
|
||||
notification["template_name"],
|
||||
notification["template_type"],
|
||||
notification["created_by_name"],
|
||||
notification["job_name"],
|
||||
notification["carrier"],
|
||||
notification["provider_response"],
|
||||
notification["status"],
|
||||
preferred_tz_created_at,
|
||||
]
|
||||
for header in original_column_headers:
|
||||
values.append(
|
||||
original_upload[notification["row_number"] - 1].get(header).data
|
||||
for header in original_column_headers
|
||||
]
|
||||
+ [
|
||||
notification["template_name"],
|
||||
notification["template_type"],
|
||||
notification["created_by_name"],
|
||||
notification["job_name"],
|
||||
notification["carrier"],
|
||||
notification["provider_response"],
|
||||
notification["status"],
|
||||
preferred_tz_created_at,
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
# TODO This is deprecated, should not be invoked. See above
|
||||
values = [
|
||||
notification["recipient"],
|
||||
notification["template_name"],
|
||||
|
||||
@@ -46,9 +46,6 @@ def _get_notifications_csv(
|
||||
"notifications": [
|
||||
{
|
||||
"row_number": row_number + i,
|
||||
"to": recipient,
|
||||
"recipient": recipient,
|
||||
"client_reference": "ref 1234",
|
||||
"template_name": template_name,
|
||||
"template_type": template_type,
|
||||
"template": {"name": template_name, "template_type": template_type},
|
||||
@@ -60,6 +57,9 @@ def _get_notifications_csv(
|
||||
"updated_at": None,
|
||||
"created_by_name": created_by_name,
|
||||
"created_by_email_address": created_by_email_address,
|
||||
"to": recipient,
|
||||
"recipient": recipient,
|
||||
"client_reference": "ref 1234",
|
||||
}
|
||||
for i in range(rows)
|
||||
],
|
||||
@@ -130,8 +130,6 @@ def test_generate_notifications_csv_without_job(
|
||||
2028675309
|
||||
""",
|
||||
[
|
||||
"Row number",
|
||||
"phone_number",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
@@ -140,10 +138,9 @@ def test_generate_notifications_csv_without_job(
|
||||
"Carrier Response",
|
||||
"Status",
|
||||
"Time",
|
||||
"phone_number",
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"2028675309",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
@@ -152,6 +149,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
"2028675309",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -160,11 +158,6 @@ def test_generate_notifications_csv_without_job(
|
||||
2028675309, 🐜,🐝,🦀
|
||||
""",
|
||||
[
|
||||
"Row number",
|
||||
"phone_number",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
@@ -173,13 +166,12 @@ def test_generate_notifications_csv_without_job(
|
||||
"Carrier Response",
|
||||
"Status",
|
||||
"Time",
|
||||
"phone_number",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"2028675309",
|
||||
"🐜",
|
||||
"🐝",
|
||||
"🦀",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
@@ -188,6 +180,10 @@ def test_generate_notifications_csv_without_job(
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
"2028675309",
|
||||
"🐜",
|
||||
"🐝",
|
||||
"🦀",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -196,11 +192,6 @@ def test_generate_notifications_csv_without_job(
|
||||
"2028675309","🐜,🐜","🐝,🐝","🦀"
|
||||
""",
|
||||
[
|
||||
"Row number",
|
||||
"phone_number",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
@@ -209,13 +200,12 @@ def test_generate_notifications_csv_without_job(
|
||||
"Carrier Response",
|
||||
"Status",
|
||||
"Time",
|
||||
"phone_number",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"2028675309",
|
||||
"🐜,🐜",
|
||||
"🐝,🐝",
|
||||
"🦀",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
@@ -224,6 +214,10 @@ def test_generate_notifications_csv_without_job(
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
"2028675309",
|
||||
"🐜,🐜",
|
||||
"🐝,🐝",
|
||||
"🦀",
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user