diff --git a/app/__init__.py b/app/__init__.py index 47a3c15e4..5292c767b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -52,8 +52,7 @@ from app.formatters import ( format_datetime_human, format_datetime_normal, format_datetime_relative, - format_datetime_short, - format_datetime_short_america, + format_datetime_table, format_day_of_week, format_delta, format_delta_days, @@ -552,8 +551,7 @@ def add_template_filters(application): format_datetime, format_datetime_24h, format_datetime_normal, - format_datetime_short, - format_datetime_short_america, + format_datetime_table, valid_phone_number, linkable_name, format_date, diff --git a/app/assets/sass/uswds/_legacy-styles.scss b/app/assets/sass/uswds/_legacy-styles.scss index b96a24844..0f16e8861 100644 --- a/app/assets/sass/uswds/_legacy-styles.scss +++ b/app/assets/sass/uswds/_legacy-styles.scss @@ -62,6 +62,14 @@ margin: -20px units(1) 20px units(1); } +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/formatters.py b/app/formatters.py index 543167d9c..c63b14776 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -87,28 +87,15 @@ def format_time(date): def format_datetime_normal(date): + # example: February 20, 2024 at 07:00 PM US/Eastern, used for datetimes that's not within tables return "{} at {} {}".format( - format_date_normal(date), format_time_24h(date), get_user_preferred_timezone() + format_date_normal(date), format_time_12h(date), get_user_preferred_timezone() ) -def format_datetime_short(date): - return "{} at {} {}".format( - format_date_short(date), format_time_24h(date), get_user_preferred_timezone() - ) - - -def format_datetime_short_america(date): - return "{} at {}".format(format_date_numeric_america(date), format_time_12h(date)) - - -def format_date_numeric_america(date): - date = parse_naive_dt(date) - - preferred_tz = pytz.timezone(get_user_preferred_timezone()) - return ( - date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%m-%d-%Y") - ) +def format_datetime_table(date): + # example: 03-18-2024 at 04:53 PM, intended for datetimes in tables + return "{} at {}".format(format_date_numeric(date), format_time_12h(date)) def format_time_12h(date): @@ -137,7 +124,7 @@ def format_date_numeric(date): preferred_tz = pytz.timezone(get_user_preferred_timezone()) return ( - date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%Y-%m-%d") + date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%m-%d-%Y") ) @@ -186,7 +173,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 774f2a916..0c0848e46 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, ) @@ -18,7 +19,7 @@ from notifications_utils.template import EmailPreviewTemplate, SMSBodyPreviewTem from app import ( current_service, - format_datetime_short, + format_datetime_table, notification_api_client, service_api_client, ) @@ -93,7 +94,7 @@ def view_job_csv(service_id, job_id): mimetype="text/csv", headers={ "Content-Disposition": 'inline; filename="{} - {}.csv"'.format( - job.template["name"], format_datetime_short(job.created_at) + job.template["name"], format_datetime_table(job.created_at) ) }, ) @@ -373,6 +374,13 @@ def get_job_partials(job): job.template_type ) + 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, "notifications": render_template( @@ -396,6 +404,7 @@ def get_job_partials(job): "status": render_template( "partials/jobs/status.html", job=job, + arrived_from_preview_page_url=arrived_from_preview_page_url, ), } diff --git a/app/main/views/send.py b/app/main/views/send.py index 8853b7fc3..3aa5bd830 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -1012,8 +1012,9 @@ def send_notification(service_id, template_id): return redirect( url_for( - ".view_notification", + ".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 diff --git a/app/templates/components/table.html b/app/templates/components/table.html index a76f2c6bd..dab53fc1f 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -171,8 +171,8 @@ {% endif %}
{{ notification.status|format_notification_status_as_time( - notification.created_at|format_datetime_short_america, - (notification.sent_at or notification.created_at)|format_datetime_short_america + notification.created_at|format_datetime_table, + (notification.sent_at or notification.created_at)|format_datetime_table ) }}
{% if displayed_on_single_line %}{% endif %} diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index b24051211..99b5768e8 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,13 +1,48 @@ +{% set display_message_status %} +{% if job.template.content %} +- {% if job.scheduled_for %} - {% if job.processing_started %} - Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_short_america }} + {% if job.still_processing or arrived_from_preview_page_url %} + {% if job.scheduled_for %} +
+ {{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_normal }} by {{ job.created_by.name }} +
++ {{ job.template_name }} - {{ current_service.name }} was sent on {{ job.created_at|format_datetime_normal }} by {{ job.created_by.name }} +
+