From c2d7828138de56c48fd78661a1faee5b0da24374 Mon Sep 17 00:00:00 2001
From: Beverly Nguyen
Date: Tue, 13 Feb 2024 17:48:06 -0800
Subject: [PATCH] created an alert for confirmation during send flow
---
app/__init__.py | 2 ++
app/formatters.py | 6 +++++
app/templates/partials/jobs/status.html | 27 ++++++++++++++++---
.../views/notifications/notification.html | 20 +++++++-------
tests/app/main/views/test_jobs.py | 14 ++++++----
tests/app/main/views/test_notifications.py | 16 ++++++++---
6 files changed, 62 insertions(+), 23 deletions(-)
diff --git a/app/__init__.py b/app/__init__.py
index 3f008f7a1..e0bde1e4e 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -53,6 +53,7 @@ from app.formatters import (
format_datetime_normal,
format_datetime_relative,
format_datetime_short,
+ format_datetime_short_12h,
format_datetime_short_america,
format_day_of_week,
format_delta,
@@ -549,6 +550,7 @@ def add_template_filters(application):
format_datetime_24h,
format_datetime_normal,
format_datetime_short,
+ format_datetime_short_12h,
format_datetime_short_america,
valid_phone_number,
linkable_name,
diff --git a/app/formatters.py b/app/formatters.py
index 543167d9c..6638160d0 100644
--- a/app/formatters.py
+++ b/app/formatters.py
@@ -98,6 +98,12 @@ def format_datetime_short(date):
)
+def format_datetime_short_12h(date):
+ return "{} at {} {}".format(
+ format_date_short(date), format_time_12h(date), get_user_preferred_timezone()
+ )
+
+
def format_datetime_short_america(date):
return "{} at {}".format(format_date_numeric_america(date), format_time_12h(date))
diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html
index 703050e8d..fb72c8382 100644
--- a/app/templates/partials/jobs/status.html
+++ b/app/templates/partials/jobs/status.html
@@ -2,12 +2,33 @@
{% if job.scheduled_for %}
{% if job.processing_started %}
- Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_short }}
+
+
+
{{ job.template_name }} - {{ current_service.name }}
+
+ Was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }}
+
+
+
{% else %}
- Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}
+
+
+
{{ job.template_name }} - {{ current_service.name }}
+
+ Was scheduled on {{ job.scheduled_for|format_datetime_short_12h }} by {{ job.created_by.name }}
+
+
+
{% endif %}
{% else %}
- Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}
+
+
+
{{ job.template_name }} - {{ current_service.name }}
+
+ Was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }}
+
+
+
{% endif %}
{% if job.status == 'sending limits exceeded'%}
diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html
index cf61250ed..9c921729d 100644
--- a/app/templates/views/notifications/notification.html
+++ b/app/templates/views/notifications/notification.html
@@ -24,18 +24,16 @@
{% if help %}
‘{{ template.name }}’
{% else %}
- ‘{{ template.name }}’
+
{% endif %}
- was sent
- {% if job and job.original_file_name != 'Report' %}
- {% set destination =
- {'email': 'an email address', 'sms': 'a phone number'} %}
- to {{ destination[template.template_type] }} from
- {{ job.original_file_name }}
- {% elif created_by %}
- by {{ created_by.name }}
- {% endif %}
- {{ created_at|format_datetime_human }}
+
+
+
{{ template.name }} - {{ current_service.name }}
+
+ Was sent on {{ created_at|format_datetime_short_12h }} by {{ created_by.name }}
+
+
+
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py
index 323a1fe00..74fd6371a 100644
--- a/tests/app/main/views/test_jobs.py
+++ b/tests/app/main/views/test_jobs.py
@@ -237,11 +237,11 @@ def test_should_show_job_with_sending_limit_exceeded_status(
job_id=fake_uuid,
)
- assert normalize_spaces(page.select("main p")[1].text) == (
+ assert normalize_spaces(page.select("main p")[2].text) == (
"Notify cannot send these messages because you have reached a limit. "
"You can only send 1,000 messages per day and 250,000 messages in total."
)
- assert normalize_spaces(page.select("main p")[2].text) == (
+ assert normalize_spaces(page.select("main p")[3].text) == (
"Upload this spreadsheet again tomorrow or contact the Notify.gov team to raise the limit."
)
@@ -350,7 +350,7 @@ def test_should_show_scheduled_job(
)
assert normalize_spaces(page.select("main div p")[1].text) == (
- "Sending Two week reminder today at 00:00 US/Eastern"
+ "Was scheduled on 2 January at 12:00 AM US/Eastern by Test User"
)
assert page.select("main p a")[0]["href"] == url_for(
@@ -425,7 +425,9 @@ def test_should_show_updates_for_one_job_as_json(
assert "Status" in content["notifications"]
assert "Delivered" in content["notifications"]
assert "00:00" in content["notifications"]
- assert "Sent by Test User on 1 January at 00:00" in content["status"]
+ assert (
+ "Was sent on 1 January at 12:00 AM US/Eastern by Test User" in content["status"]
+ )
@freeze_time("2016-01-01 05:00:00.000001")
@@ -467,7 +469,9 @@ def test_should_show_updates_for_scheduled_job_as_json(
assert "Status" in content["notifications"]
assert "Delivered" in content["notifications"]
assert "00:00" in content["notifications"]
- assert "Sent by Test User on 1 June at 16:00" in content["status"]
+ assert (
+ "Was sent on 1 January at 12:00 AM US/Eastern by Test User" in content["status"]
+ )
@pytest.mark.parametrize(
diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py
index 7020cd3e0..61a7f495d 100644
--- a/tests/app/main/views/test_notifications.py
+++ b/tests/app/main/views/test_notifications.py
@@ -226,22 +226,30 @@ def test_notification_status_shows_expected_back_link(
[
(
"2012-01-01 06:01",
- ("‘sample template’ was sent by Test User today at 01:01 US/Eastern"),
+ (
+ "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern "
+ "by Test User"
+ ),
),
(
"2012-01-02 06:01",
- ("‘sample template’ was sent by Test User yesterday at 01:01 US/Eastern"),
+ (
+ "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern "
+ "by Test User"
+ ),
),
(
"2012-01-03 06:01",
(
- "‘sample template’ was sent by Test User on 1 January at 01:01 US/Eastern"
+ "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern "
+ "by Test User"
),
),
(
"2013-01-03 06:01",
(
- "‘sample template’ was sent by Test User on 1 January 2012 at 01:01 US/Eastern"
+ "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern "
+ "by Test User"
),
),
],