mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into 963-message-parts-content-updates
This commit is contained in:
@@ -11,12 +11,7 @@ from flask import (
|
|||||||
url_for,
|
url_for,
|
||||||
)
|
)
|
||||||
|
|
||||||
from app import (
|
from app import current_service, job_api_client, notification_api_client
|
||||||
current_service,
|
|
||||||
format_date_numeric,
|
|
||||||
job_api_client,
|
|
||||||
notification_api_client,
|
|
||||||
)
|
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.notify_client.api_key_api_client import KEY_TYPE_TEST
|
from app.notify_client.api_key_api_client import KEY_TYPE_TEST
|
||||||
from app.utils import (
|
from app.utils import (
|
||||||
@@ -26,7 +21,7 @@ from app.utils import (
|
|||||||
parse_filter_args,
|
parse_filter_args,
|
||||||
set_status_filters,
|
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.templates import get_template
|
||||||
from app.utils.user import user_has_permissions
|
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(
|
service_data_retention_days = current_service.get_days_of_retention(
|
||||||
filter_args.get("message_type")[0]
|
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(
|
return Response(
|
||||||
stream_with_context(
|
stream_with_context(
|
||||||
generate_notifications_csv(
|
generate_notifications_csv(
|
||||||
@@ -162,7 +160,7 @@ def download_notifications_csv(service_id):
|
|||||||
mimetype="text/csv",
|
mimetype="text/csv",
|
||||||
headers={
|
headers={
|
||||||
"Content-Disposition": 'inline; filename="{} - {} - {} report.csv"'.format(
|
"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],
|
filter_args["message_type"][0],
|
||||||
current_service.name,
|
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)
|
utc_date_obj = utc_date_obj.astimezone(pytz.utc)
|
||||||
preferred_timezone = pytz.timezone(get_user_preferred_timezone())
|
preferred_timezone = pytz.timezone(get_user_preferred_timezone())
|
||||||
preferred_date_obj = utc_date_obj.astimezone(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()}"
|
return f"{preferred_tz_created_at} {get_user_preferred_timezone()}"
|
||||||
|
|
||||||
|
|||||||
15
poetry.lock
generated
15
poetry.lock
generated
@@ -1428,16 +1428,6 @@ files = [
|
|||||||
{file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"},
|
{file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"},
|
||||||
{file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"},
|
{file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"},
|
||||||
{file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"},
|
{file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"},
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"},
|
|
||||||
{file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"},
|
{file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"},
|
||||||
{file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"},
|
{file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"},
|
||||||
{file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"},
|
{file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"},
|
||||||
@@ -1700,7 +1690,7 @@ requests = ">=2.0.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notifications-utils"
|
name = "notifications-utils"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
description = ""
|
description = ""
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.9,<3.12"
|
python-versions = ">=3.9,<3.12"
|
||||||
@@ -1752,7 +1742,7 @@ werkzeug = "^3.0.1"
|
|||||||
type = "git"
|
type = "git"
|
||||||
url = "https://github.com/GSA/notifications-utils.git"
|
url = "https://github.com/GSA/notifications-utils.git"
|
||||||
reference = "HEAD"
|
reference = "HEAD"
|
||||||
resolved_reference = "f183d120a8b86e655405694adde1f0d95e4e5a51"
|
resolved_reference = "b6cee72f45dbcd48b59447fa08bbac59e15a7b98"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "numpy"
|
name = "numpy"
|
||||||
@@ -2476,7 +2466,6 @@ files = [
|
|||||||
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
|
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
|
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
|
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
|
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
|
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
|
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
|
||||||
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
|
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
|
||||||
|
|||||||
@@ -1955,7 +1955,7 @@ def test_set_template_sender(
|
|||||||
"sms",
|
"sms",
|
||||||
False,
|
False,
|
||||||
"a" * 160,
|
"a" * 160,
|
||||||
"Will be charged as 2 text messages",
|
"Will be charged as 1 text message",
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@@ -1969,7 +1969,7 @@ def test_set_template_sender(
|
|||||||
"sms",
|
"sms",
|
||||||
True,
|
True,
|
||||||
"a" * 147,
|
"a" * 147,
|
||||||
"Will be charged as 2 text messages",
|
"Will be charged as 1 text message",
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@@ -1984,7 +1984,7 @@ def test_set_template_sender(
|
|||||||
"sms",
|
"sms",
|
||||||
False,
|
False,
|
||||||
"a" * 918,
|
"a" * 918,
|
||||||
"Will be charged as 7 text messages",
|
"Will be charged as 6 text messages",
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@@ -2025,11 +2025,8 @@ def test_set_template_sender(
|
|||||||
(
|
(
|
||||||
"sms",
|
"sms",
|
||||||
False,
|
False,
|
||||||
# The length of this string in bytes is 210, needing two fragments.
|
|
||||||
# Seems like previous calculation was wrong unless the number of characters
|
|
||||||
# somehow has priority over the number of bytes in a fragment (?)
|
|
||||||
"Ẅ" * 70,
|
"Ẅ" * 70,
|
||||||
"Will be charged as 2 text messages",
|
"Will be charged as 1 text message. Use of characters outside the IEC_8859-1 character set may increase the message fragment count, resulting in additional charges, and these IEC_8859-1 characters may not display properly on some older mobile devices.", # noqa E501
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@@ -2043,11 +2040,7 @@ def test_set_template_sender(
|
|||||||
"sms",
|
"sms",
|
||||||
False,
|
False,
|
||||||
"Ẅ" * 918,
|
"Ẅ" * 918,
|
||||||
# The length of this string in bytes is 2754. Divide by 140 and we get 19. Then round up.
|
"Will be charged as 14 text messages",
|
||||||
# Don't know why it was previously calculated as 14. They seem to have charged by characters
|
|
||||||
# rather than length of the fragment in bytes.
|
|
||||||
# "Will be charged as 14 text messages",
|
|
||||||
"Will be charged as 20 text messages",
|
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -91,14 +91,14 @@ def get_notifications_csv_mock(
|
|||||||
None,
|
None,
|
||||||
[
|
[
|
||||||
"Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
|
"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",
|
"Anne Example",
|
||||||
[
|
[
|
||||||
"Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
|
"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",
|
"ATT Mobility",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"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",
|
"ATT Mobility",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"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",
|
"ATT Mobility",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"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():
|
def test_convert_report_date_to_preferred_timezone():
|
||||||
original = "2023-11-16 05:00:00"
|
original = "2023-11-16 05:00:00"
|
||||||
altered = convert_report_date_to_preferred_timezone(original)
|
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