From c2d7828138de56c48fd78661a1faee5b0da24374 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 13 Feb 2024 17:48:06 -0800 Subject: [PATCH 01/15] 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" ), ), ], From 4eb886d8c026d780bc8dd241fe256b694bdbfe5d Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 13 Feb 2024 18:18:13 -0800 Subject: [PATCH 02/15] update test --- .../views/notifications/notification.html | 28 ++++++++----------- tests/app/main/views/test_notifications.py | 18 ++++-------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 9c921729d..5a03daf3d 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -20,26 +20,20 @@ {{ page_header( 1|message_count_label(template.template_type, suffix='') | capitalize ) }} -

- {% if help %} - ‘{{ template.name }}’ - {% else %} - - {% endif %} -

-
-

{{ template.name }} - {{ current_service.name }}

-

- Was sent on {{ created_at|format_datetime_short_12h }} by {{ created_by.name }} -

-
+ {% if help %} +

‘{{ template.name }}’

+ {% endif %} +
+
+

{{ template.name }} - {{ current_service.name }}

+

+ Was sent on {{ created_at|format_datetime_short_12h }} by {{ created_by.name }} +

-

- -
- {{ template|string }}
+ {{ template|string }} + {% if template.template_type == 'email' %}
{{ ajax_block(partials, updates_url, 'status', finished=finished) }} diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 61a7f495d..ce7bcab63 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -227,29 +227,25 @@ def test_notification_status_shows_expected_back_link( ( "2012-01-01 06:01", ( - "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern " - "by Test User" + "Was sent on 1 January at 01:01 AM US/Eastern by Test User" ), ), ( "2012-01-02 06:01", ( - "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern " - "by Test User" + "Was sent on 1 January at 01:01 AM US/Eastern by Test User" ), ), ( "2012-01-03 06:01", ( - "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern " - "by Test User" + "Was sent on 1 January at 01:01 AM US/Eastern by Test User" ), ), ( "2013-01-03 06:01", ( - "‘sample template’ sample template - service one Was sent on 1 January at 01:01 AM US/Eastern " - "by Test User" + "Was sent on 1 January at 01:01 AM US/Eastern by Test User" ), ), ], @@ -275,10 +271,8 @@ def test_notification_page_doesnt_link_to_template_in_tour( notification_id=fake_uuid, help=3, ) - - assert normalize_spaces(page.select("main p:nth-of-type(1)")[0].text) == ( - expected_message - ) + p_text = normalize_spaces(page.select_one(".usa-alert__text").text) + assert p_text == normalize_spaces(expected_message) assert len(page.select("main p:nth-of-type(1) a")) == 0 From 1e60da1a3736583b1194e13bf57738b8eb649a03 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 22 Feb 2024 11:59:12 -0800 Subject: [PATCH 03/15] add job status --- app/assets/sass/uswds/_legacy-styles.scss | 6 ++- app/formatters.py | 5 ++- app/main/views/jobs.py | 5 +++ app/templates/partials/jobs/status.html | 55 ++++++++++++++--------- app/templates/views/jobs/job.html | 19 ++------ 5 files changed, 51 insertions(+), 39 deletions(-) diff --git a/app/assets/sass/uswds/_legacy-styles.scss b/app/assets/sass/uswds/_legacy-styles.scss index 3b09e2218..b62c15c36 100644 --- a/app/assets/sass/uswds/_legacy-styles.scss +++ b/app/assets/sass/uswds/_legacy-styles.scss @@ -62,6 +62,10 @@ margin: -20px units(1) 20px units(1); } +h2.sms-message-header { + margin-bottom: 0.5rem; +} + .sms-message-status-outbound { text-align: right; } @@ -131,7 +135,7 @@ &-label, &-button-label { font-weight: bold; - font-size: 19px; + font-size: 19px; display: block; margin: 0 0 10px 0; } diff --git a/app/formatters.py b/app/formatters.py index 6638160d0..db9f8dc04 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -99,8 +99,9 @@ def format_datetime_short(date): def format_datetime_short_12h(date): + # example: February 20, 2024 at 07:00 PM US/Eastern return "{} at {} {}".format( - format_date_short(date), format_time_12h(date), get_user_preferred_timezone() + format_date_normal(date), format_time_12h(date), get_user_preferred_timezone() ) @@ -192,7 +193,7 @@ def format_date(date): def format_date_normal(date): date = parse_naive_dt(date) - return date.strftime("%d %B %Y").lstrip("0") + return date.strftime("%B %d, %Y").lstrip("0") def format_date_short(date): diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index ed8f051a3..8f856f867 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -10,6 +10,7 @@ from flask import ( redirect, render_template, request, + session, stream_with_context, url_for, ) @@ -369,6 +370,9 @@ def get_job_partials(job): job.template_type ) + session['came_from_preview_page'] = 'check' in request.referrer + came_from_preview_page_url = session.get('came_from_preview_page', False) + return { "counts": counts, "notifications": render_template( @@ -392,6 +396,7 @@ def get_job_partials(job): "status": render_template( "partials/jobs/status.html", job=job, + came_from_preview_page_url=came_from_preview_page_url ), } diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index fb72c8382..15703b01c 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,34 +1,49 @@

- {% if job.scheduled_for %} - {% if job.processing_started %} -

-
-

{{ job.template_name }} - {{ current_service.name }}

-

- Was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }} -

+ {% set display_message_status %} + {% if job.template.content %} +

Message

+
{{ current_service.name }}: {{job.template.content}}
+ {% endif %} + {% if job.original_file_name %} +

Recipients list

+
+
    +
  • + Description Icon +
    +

    {{ job.original_file_name }}

    +
    +
  • +
-
- {% else %} + {% endif %} +

SMS Status

+ {% endset %} + {% if job.scheduled_for %} + {% if came_from_preview_page_url %}
-

{{ job.template_name }} - {{ current_service.name }}

+

Your text has been scheduled

- Was scheduled on {{ job.scheduled_for|format_datetime_short_12h }} by {{ job.created_by.name }} + {{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_short_12h }} by {{ job.created_by.name }}

+ {{display_message_status}} {% endif %} - {% else %} -
-
-

{{ job.template_name }} - {{ current_service.name }}

-

- Was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }} -

+ {% else %} + {% if came_from_preview_page_url %} +
+
+

Your text has been sent

+

+ {{ job.template_name }} - {{ current_service.name }} was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }} +

+
-
+ {{display_message_status}} + {% endif %} {% endif %}

{% if job.status == 'sending limits exceeded'%} diff --git a/app/templates/views/jobs/job.html b/app/templates/views/jobs/job.html index 0c334a634..ce4e94b3d 100644 --- a/app/templates/views/jobs/job.html +++ b/app/templates/views/jobs/job.html @@ -5,26 +5,13 @@ {% from "components/components/back-link/macro.njk" import usaBackLink %} {% block service_page_title %} - {{ job.original_file_name }} + {{ "Message status" }} {% endblock %} {% block maincolumn_content %} - {{ page_header(job.original_file_name) }} - - {% if not job.processing_finished %} -
- {% endif %} - {{ partials['status']|safe }} - {% if not job.processing_finished %} -
- {% endif %} - + {{ page_header("Message status") }} + {{ partials['status']|safe }} {% if not finished %}
Date: Fri, 23 Feb 2024 13:26:46 -0800 Subject: [PATCH 04/15] updated testing --- app/assets/sass/uswds/_legacy-styles.scss | 4 ++ app/main/views/jobs.py | 10 +++-- app/templates/partials/jobs/status.html | 49 +++++++++++------------ tests/app/main/views/test_jobs.py | 12 +++--- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/app/assets/sass/uswds/_legacy-styles.scss b/app/assets/sass/uswds/_legacy-styles.scss index b62c15c36..599c3860f 100644 --- a/app/assets/sass/uswds/_legacy-styles.scss +++ b/app/assets/sass/uswds/_legacy-styles.scss @@ -66,6 +66,10 @@ h2.sms-message-header { margin-bottom: 0.5rem; } +h2.recipient-list { + margin-bottom: 0.5rem; +} + .sms-message-status-outbound { text-align: right; } diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 8f856f867..afaaf6465 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -370,8 +370,12 @@ def get_job_partials(job): job.template_type ) - session['came_from_preview_page'] = 'check' in request.referrer - came_from_preview_page_url = session.get('came_from_preview_page', False) + if request.referrer is not None: + session["arrived_from_preview_page"] = "check" in request.referrer + else: + session["arrived_from_preview_page"] = False + + arrived_from_preview_page_url = session.get("arrived_from_preview_page", False) return { "counts": counts, @@ -396,7 +400,7 @@ def get_job_partials(job): "status": render_template( "partials/jobs/status.html", job=job, - came_from_preview_page_url=came_from_preview_page_url + arrived_from_preview_page_url=arrived_from_preview_page_url, ), } diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 15703b01c..e01e356a2 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,27 +1,28 @@ +{% set display_message_status %} +{% if job.template.content %} +

Message

+
{{ current_service.name }}: {{job.template.content}}
+{% endif %} +{% if job.original_file_name %} +

Recipient list

+
+
    +
  • + Description Icon +
    +

    {{ job.original_file_name }}

    +
    +
  • +
+
+{% endif %} +

SMS Status

+{% endset %} +

- {% set display_message_status %} - {% if job.template.content %} -

Message

-
{{ current_service.name }}: {{job.template.content}}
- {% endif %} - {% if job.original_file_name %} -

Recipients list

-
-
    -
  • - Description Icon -
    -

    {{ job.original_file_name }}

    -
    -
  • -
-
- {% endif %} -

SMS Status

- {% endset %} - {% if job.scheduled_for %} - {% if came_from_preview_page_url %} + {% if job.still_processing or arrived_from_preview_page_url %} + {% if job.scheduled_for %}

Your text has been scheduled

@@ -31,9 +32,7 @@
{{display_message_status}} - {% endif %} - {% else %} - {% if came_from_preview_page_url %} + {% else %}

Your text has been sent

diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 74fd6371a..caffa01bb 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -13,7 +13,7 @@ from tests.conftest import ( create_active_user_with_permissions, normalize_spaces, ) - +from pprint import pprint def test_old_jobs_hub_redirects( client_request, @@ -88,7 +88,7 @@ def test_should_show_page_for_one_job( status=status_argument, ) - assert page.h1.text.strip() == "thisisatest.csv" + assert page.h1.text.strip() == "Message status" assert " ".join(page.find("tbody").find("tr").text.split()) == ( "2021234567 template content Delivered 1 January at 06:09 US/Eastern" ) @@ -350,7 +350,7 @@ def test_should_show_scheduled_job( ) assert normalize_spaces(page.select("main div p")[1].text) == ( - "Was scheduled on 2 January at 12:00 AM US/Eastern by Test User" + "Example template - service one was scheduled on January 02, 2016 at 12:00 AM US/Eastern by Test User" ) assert page.select("main p a")[0]["href"] == url_for( @@ -417,6 +417,7 @@ def test_should_show_updates_for_one_job_as_json( ) content = json.loads(response.get_data(as_text=True)) + pprint(content) assert "pending" in content["counts"] assert "delivered" in content["counts"] assert "failed" in content["counts"] @@ -425,9 +426,6 @@ 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 ( - "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") @@ -470,7 +468,7 @@ def test_should_show_updates_for_scheduled_job_as_json( assert "Delivered" in content["notifications"] assert "00:00" in content["notifications"] assert ( - "Was sent on 1 January at 12:00 AM US/Eastern by Test User" in content["status"] + "Was sent on 1 January at 12:00 AM US/Eastern by Test User" ) From 2ee744e56d77aee6a8b60f2eee247d0b389bea05 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 13:31:49 -0800 Subject: [PATCH 05/15] fixed spacing --- tests/app/main/views/test_jobs.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index caffa01bb..6c9192a15 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -13,7 +13,6 @@ from tests.conftest import ( create_active_user_with_permissions, normalize_spaces, ) -from pprint import pprint def test_old_jobs_hub_redirects( client_request, @@ -417,7 +416,6 @@ def test_should_show_updates_for_one_job_as_json( ) content = json.loads(response.get_data(as_text=True)) - pprint(content) assert "pending" in content["counts"] assert "delivered" in content["counts"] assert "failed" in content["counts"] From fff70d4edc47cf0b95f1b836d1a7385587f11e13 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 13:37:48 -0800 Subject: [PATCH 06/15] fixed spacing --- tests/app/main/views/test_jobs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 6c9192a15..8f82ce1d9 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -14,6 +14,7 @@ from tests.conftest import ( normalize_spaces, ) + def test_old_jobs_hub_redirects( client_request, ): From 0981990086ad5d1804caee3aee2a44e118c93bdf Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 14:50:26 -0800 Subject: [PATCH 07/15] update testing --- app/main/views/send.py | 36 +++++++++---------- .../views/notifications/notification.html | 26 +++++++++----- tests/app/main/views/test_send.py | 2 +- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 4332c7ddb..10f74bb41 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -52,12 +52,14 @@ def get_example_csv_fields(column_headers, use_example_as_example, submitted_fie def get_example_csv_rows(template, use_example_as_example=True, submitted_fields=False): return { - "email": ["test@example.com"] - if use_example_as_example - else [current_user.email_address], - "sms": ["12223334444"] - if use_example_as_example - else [current_user.mobile_number], + "email": ( + ["test@example.com"] + if use_example_as_example + else [current_user.email_address] + ), + "sms": ( + ["12223334444"] if use_example_as_example else [current_user.mobile_number] + ), }[template.template_type] + get_example_csv_fields( ( placeholder @@ -511,12 +513,14 @@ def _check_messages(service_id, template_id, upload_id, preview_row): template=template, max_initial_rows_shown=50, max_errors_shown=50, - guestlist=itertools.chain.from_iterable( - [user.name, user.mobile_number, user.email_address] - for user in Users(service_id) - ) - if current_service.trial_mode - else None, + guestlist=( + itertools.chain.from_iterable( + [user.name, user.mobile_number, user.email_address] + for user in Users(service_id) + ) + if current_service.trial_mode + else None + ), remaining_messages=remaining_messages, allow_international_sms=current_service.has_permission("international_sms"), ) @@ -905,13 +909,9 @@ def send_notification(service_id, template_id): return redirect( url_for( - ".view_notification", + ".view_job", service_id=service_id, - from_job=upload_id, - notification_id=notifications["notifications"][0]["id"], - # used to show the final step of the tour (help=3) or not show - # a back link on a just sent one off notification (help=0) - help=request.args.get("help"), + job_id=upload_id, ) ) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 5a03daf3d..e5a41d422 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -20,19 +20,27 @@ {{ page_header( 1|message_count_label(template.template_type, suffix='') | capitalize ) }} +

{% if help %} -

‘{{ template.name }}’

+ ‘{{ template.name }}’ + {% else %} + ‘{{ template.name }}’ {% endif %} -
-
-

{{ template.name }} - {{ current_service.name }}

-

- Was sent on {{ created_at|format_datetime_short_12h }} by {{ created_by.name }} + 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|string }} +
+ {{ template|string }} +
{% if template.template_type == 'email' %}
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 7448c44cf..c1714c668 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -2056,7 +2056,7 @@ def test_create_job_should_call_api( _expected_status=200, ) - assert original_file_name in page.text + assert "Message status" in page.text mock_create_job.assert_called_with( job_id, From fd340ed1051e6c5e1500b54748489aac036419fd Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 14:59:25 -0800 Subject: [PATCH 08/15] update test --- tests/app/main/views/test_notifications.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index ce7bcab63..2d1ac37b4 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -226,26 +226,22 @@ def test_notification_status_shows_expected_back_link( [ ( "2012-01-01 06:01", - ( - "Was sent on 1 January at 01:01 AM US/Eastern by Test User" - ), + ("‘sample template’ was sent by Test User today at 01:01 US/Eastern"), ), ( "2012-01-02 06:01", - ( - "Was sent on 1 January at 01:01 AM US/Eastern by Test User" - ), + ("‘sample template’ was sent by Test User yesterday at 01:01 US/Eastern"), ), ( "2012-01-03 06:01", ( - "Was sent on 1 January at 01:01 AM US/Eastern by Test User" + "‘sample template’ was sent by Test User on 1 January at 01:01 US/Eastern" ), ), ( "2013-01-03 06:01", ( - "Was sent on 1 January at 01:01 AM US/Eastern by Test User" + "‘sample template’ was sent by Test User on 1 January 2012 at 01:01 US/Eastern" ), ), ], @@ -271,8 +267,6 @@ def test_notification_page_doesnt_link_to_template_in_tour( notification_id=fake_uuid, help=3, ) - p_text = normalize_spaces(page.select_one(".usa-alert__text").text) - assert p_text == normalize_spaces(expected_message) assert len(page.select("main p:nth-of-type(1) a")) == 0 From d08968a34815bb6ae5f8bbea4dbad02a93caae01 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 15:02:18 -0800 Subject: [PATCH 09/15] update test --- app/main/views/send.py | 28 ++++++++----------- .../views/notifications/notification.html | 12 ++++---- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 10f74bb41..d45c1909f 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -52,14 +52,12 @@ def get_example_csv_fields(column_headers, use_example_as_example, submitted_fie def get_example_csv_rows(template, use_example_as_example=True, submitted_fields=False): return { - "email": ( - ["test@example.com"] - if use_example_as_example - else [current_user.email_address] - ), - "sms": ( - ["12223334444"] if use_example_as_example else [current_user.mobile_number] - ), + "email": ["test@example.com"] + if use_example_as_example + else [current_user.email_address], + "sms": ["12223334444"] + if use_example_as_example + else [current_user.mobile_number], }[template.template_type] + get_example_csv_fields( ( placeholder @@ -513,14 +511,12 @@ def _check_messages(service_id, template_id, upload_id, preview_row): template=template, max_initial_rows_shown=50, max_errors_shown=50, - guestlist=( - itertools.chain.from_iterable( - [user.name, user.mobile_number, user.email_address] - for user in Users(service_id) - ) - if current_service.trial_mode - else None - ), + guestlist=itertools.chain.from_iterable( + [user.name, user.mobile_number, user.email_address] + for user in Users(service_id) + ) + if current_service.trial_mode + else None, remaining_messages=remaining_messages, allow_international_sms=current_service.has_permission("international_sms"), ) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index e5a41d422..cf61250ed 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -20,13 +20,13 @@ {{ page_header( 1|message_count_label(template.template_type, suffix='') | capitalize ) }} -

- {% if help %} - ‘{{ template.name }}’ +

+ {% if help %} + ‘{{ template.name }}’ {% else %} ‘{{ template.name }}’ - {% endif %} - was sent + {% endif %} + was sent {% if job and job.original_file_name != 'Report' %} {% set destination = {'email': 'an email address', 'sms': 'a phone number'} %} @@ -36,7 +36,7 @@ by {{ created_by.name }} {% endif %} {{ created_at|format_datetime_human }} -

+

{{ template|string }} From 039b7cdece8dbe078de3807b3b4a8aa4d42fadd8 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 15:14:54 -0800 Subject: [PATCH 10/15] update test --- tests/app/main/views/test_performance.py | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/app/main/views/test_performance.py b/tests/app/main/views/test_performance.py index ef2ed06be..5ceb5288b 100644 --- a/tests/app/main/views/test_performance.py +++ b/tests/app/main/views/test_performance.py @@ -116,26 +116,26 @@ def test_should_render_performance_page( "" "Messages sent since May 2023 " "Date Emails Text messages " - "27 February 2021 1 2 " - "26 February 2021 1 2 " - "25 February 2021 1 2 " - "24 February 2021 1 2 " - "23 February 2021 1 2 " - "22 February 2021 1 2 " - "21 February 2021 1,234,567 123,456 " + "February 27, 2021 1 2 " + "February 26, 2021 1 2 " + "February 25, 2021 1 2 " + "February 24, 2021 1 2 " + "February 23, 2021 1 2 " + "February 22, 2021 1 2 " + "February 21, 2021 1,234,567 123,456 " "Only showing the last 7 days " "" "Messages sent within 10 seconds " "98.31% on average " "Messages sent within 10 seconds " "Date Percentage " - "27 February 2021 98.60% " - "26 February 2021 100.00% " - "25 February 2021 99.99% " - "24 February 2021 100.00% " - "23 February 2021 95.00% " - "22 February 2021 95.30% " - "21 February 2021 99.25% " + "February 27, 2021 98.60% " + "February 26, 2021 100.00% " + "February 25, 2021 99.99% " + "February 24, 2021 100.00% " + "February 23, 2021 95.00% " + "February 22, 2021 95.30% " + "February 21, 2021 99.25% " "Only showing the last 7 days " "" "Organizations using Notify " From 58e252f092b751a645d76c71f14381f2fe39c1a8 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Mon, 26 Feb 2024 12:25:53 -0800 Subject: [PATCH 11/15] updated Delivery Status title --- app/templates/partials/jobs/status.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index e01e356a2..858a4ff10 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -16,7 +16,7 @@
{% endif %} -

SMS Status

+

Delivery Status

{% endset %}
From ee5fe38001748f13768fcff16ce9687699852cc1 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 8 Mar 2024 11:30:49 -0800 Subject: [PATCH 12/15] update testing --- app/main/views/send.py | 5 +++++ tests/app/main/views/test_jobs.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 10f74bb41..3ca38171b 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -912,6 +912,11 @@ def send_notification(service_id, template_id): ".view_job", service_id=service_id, job_id=upload_id, + from_job=upload_id, + notification_id=notifications["notifications"][0]["id"], + # used to show the final step of the tour (help=3) or not show + # a back link on a just sent one off notification (help=0) + help=request.args.get("help"), ) ) diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index c7afce860..9e04cdf21 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -424,7 +424,7 @@ def test_should_show_updates_for_one_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert "00:00" in content["notifications"] + assert "01-01-2016 at 12:00 AM" in content["notifications"] @freeze_time("2016-01-01 05:00:00.000001") @@ -465,7 +465,7 @@ def test_should_show_updates_for_scheduled_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert "00:00" in content["notifications"] + assert "01-01-2016 at 12:00 AM" in content["notifications"] assert ( "Was sent on 1 January at 12:00 AM US/Eastern by Test User" ) From b1b416db8c06fd7c1ee5466e49e4fb0523df5396 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 8 Mar 2024 11:43:54 -0800 Subject: [PATCH 13/15] update datetime naming --- app/__init__.py | 4 ++-- app/formatters.py | 2 +- app/templates/partials/jobs/status.html | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 889a016a8..e605306ed 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -53,7 +53,7 @@ from app.formatters import ( format_datetime_normal, format_datetime_relative, format_datetime_short, - format_datetime_short_12h, + format_datetime_text, format_datetime_short_america, format_day_of_week, format_delta, @@ -554,7 +554,7 @@ def add_template_filters(application): format_datetime_24h, format_datetime_normal, format_datetime_short, - format_datetime_short_12h, + format_datetime_text, format_datetime_short_america, valid_phone_number, linkable_name, diff --git a/app/formatters.py b/app/formatters.py index db9f8dc04..f06d282dc 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -98,7 +98,7 @@ def format_datetime_short(date): ) -def format_datetime_short_12h(date): +def format_datetime_text(date): # example: February 20, 2024 at 07:00 PM US/Eastern return "{} at {} {}".format( format_date_normal(date), format_time_12h(date), get_user_preferred_timezone() diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 858a4ff10..d9b8ec505 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -27,7 +27,7 @@

Your text has been scheduled

- {{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_short_12h }} by {{ job.created_by.name }} + {{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_text }} by {{ job.created_by.name }}

@@ -37,7 +37,7 @@

Your text has been sent

- {{ job.template_name }} - {{ current_service.name }} was sent on {{ job.created_at|format_datetime_short_12h }} by {{ job.created_by.name }} + {{ job.template_name }} - {{ current_service.name }} was sent on {{ job.created_at|format_datetime_text }} by {{ job.created_by.name }}

From 335b01279b7bca37af9de3f2ac59559f1ab113a9 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 8 Mar 2024 11:54:19 -0800 Subject: [PATCH 14/15] fix sorted imports --- app/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index e605306ed..f917b9120 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -53,8 +53,8 @@ from app.formatters import ( format_datetime_normal, format_datetime_relative, format_datetime_short, - format_datetime_text, format_datetime_short_america, + format_datetime_text, format_day_of_week, format_delta, format_delta_days, @@ -554,8 +554,8 @@ def add_template_filters(application): format_datetime_24h, format_datetime_normal, format_datetime_short, - format_datetime_text, format_datetime_short_america, + format_datetime_text, valid_phone_number, linkable_name, format_date, From 89e7de0ab6cddf9a3e653ed134a015c5e40c2fda Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 26 Mar 2024 12:37:06 -0700 Subject: [PATCH 15/15] fixed the testing --- tests/app/main/views/test_jobs.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 23eb8fc34..ec63858bc 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -424,11 +424,7 @@ def test_should_show_updates_for_one_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert ( - "Sent by Test User on January 01, 2016 at 12:00 AM US/Eastern" - in content["status"] - ) - assert "12:00" in content["notifications"] + assert "01-01-2016 at 12:00 AM" in content["notifications"] @freeze_time("2016-01-01 05:00:00.000001") @@ -469,10 +465,7 @@ def test_should_show_updates_for_scheduled_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert ( - "Sent by Test User on June 01, 2016 at 04:00 PM US/Eastern" in content["status"] - ) - assert "12:00" in content["notifications"] + assert "01-01-2016 at 12:00 AM" in content["notifications"] @pytest.mark.parametrize(