mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Merge pull request #1140 from GSA/notify-admin-1090
change download reports to 12 hour time (notify-admin-1090)
This commit is contained in:
@@ -11,12 +11,7 @@ from flask import (
|
||||
url_for,
|
||||
)
|
||||
|
||||
from app import (
|
||||
current_service,
|
||||
format_date_numeric,
|
||||
job_api_client,
|
||||
notification_api_client,
|
||||
)
|
||||
from app import current_service, job_api_client, notification_api_client
|
||||
from app.main import main
|
||||
from app.notify_client.api_key_api_client import KEY_TYPE_TEST
|
||||
from app.utils import (
|
||||
@@ -26,7 +21,7 @@ from app.utils import (
|
||||
parse_filter_args,
|
||||
set_status_filters,
|
||||
)
|
||||
from app.utils.csv import generate_notifications_csv
|
||||
from app.utils.csv import generate_notifications_csv, get_user_preferred_timezone
|
||||
from app.utils.templates import get_template
|
||||
from app.utils.user import user_has_permissions
|
||||
|
||||
@@ -146,6 +141,9 @@ def download_notifications_csv(service_id):
|
||||
service_data_retention_days = current_service.get_days_of_retention(
|
||||
filter_args.get("message_type")[0]
|
||||
)
|
||||
file_time = datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
||||
file_time = f"{file_time} {get_user_preferred_timezone()}"
|
||||
|
||||
return Response(
|
||||
stream_with_context(
|
||||
generate_notifications_csv(
|
||||
@@ -162,7 +160,7 @@ def download_notifications_csv(service_id):
|
||||
mimetype="text/csv",
|
||||
headers={
|
||||
"Content-Disposition": 'inline; filename="{} - {} - {} report.csv"'.format(
|
||||
format_date_numeric(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
|
||||
file_time,
|
||||
filter_args["message_type"][0],
|
||||
current_service.name,
|
||||
)
|
||||
|
||||
@@ -170,7 +170,7 @@ def convert_report_date_to_preferred_timezone(db_date_str_in_utc):
|
||||
utc_date_obj = utc_date_obj.astimezone(pytz.utc)
|
||||
preferred_timezone = pytz.timezone(get_user_preferred_timezone())
|
||||
preferred_date_obj = utc_date_obj.astimezone(preferred_timezone)
|
||||
preferred_tz_created_at = preferred_date_obj.strftime("%Y-%m-%d %H:%M:%S")
|
||||
preferred_tz_created_at = preferred_date_obj.strftime("%Y-%m-%d %I:%M:%S %p")
|
||||
|
||||
return f"{preferred_tz_created_at} {get_user_preferred_timezone()}"
|
||||
|
||||
|
||||
@@ -91,14 +91,14 @@ def get_notifications_csv_mock(
|
||||
None,
|
||||
[
|
||||
"Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
|
||||
"foo@bar.com,foo,sms,,,ATT Mobility,Did not like it,Delivered,1943-04-19 08:00:00 US/Eastern\r\n",
|
||||
"foo@bar.com,foo,sms,,,ATT Mobility,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n",
|
||||
],
|
||||
),
|
||||
(
|
||||
"Anne Example",
|
||||
[
|
||||
"Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
|
||||
"foo@bar.com,foo,sms,Anne Example,,ATT Mobility,Did not like it,Delivered,1943-04-19 08:00:00 US/Eastern\r\n", # noqa
|
||||
"foo@bar.com,foo,sms,Anne Example,,ATT Mobility,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n", # noqa
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -151,7 +151,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"ATT Mobility",
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 US/Eastern",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -187,7 +187,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"ATT Mobility",
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 US/Eastern",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -223,7 +223,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"ATT Mobility",
|
||||
"Did not like it",
|
||||
"Delivered",
|
||||
"1943-04-19 08:00:00 US/Eastern",
|
||||
"1943-04-19 08:00:00 AM US/Eastern",
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -398,4 +398,4 @@ def test_get_errors_for_csv(
|
||||
def test_convert_report_date_to_preferred_timezone():
|
||||
original = "2023-11-16 05:00:00"
|
||||
altered = convert_report_date_to_preferred_timezone(original)
|
||||
assert altered == "2023-11-16 00:00:00 US/Eastern"
|
||||
assert altered == "2023-11-16 12:00:00 AM US/Eastern"
|
||||
|
||||
Reference in New Issue
Block a user