mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-27 11:19:21 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into sms-allowance-dashboardbug
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -171,8 +171,8 @@
|
||||
{% endif %}
|
||||
<p class="status-hint margin-0 width-card ">
|
||||
{{ 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
|
||||
) }}
|
||||
</p>
|
||||
{% if displayed_on_single_line %}</span>{% endif %}
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
{% set display_message_status %}
|
||||
{% if job.template.content %}
|
||||
<h2 class="sms-message-header">Message</h2>
|
||||
<div class="sms-message-wrapper">{{ current_service.name }}: {{job.template.content}}</div>
|
||||
{% endif %}
|
||||
{% if job.original_file_name %}
|
||||
<h2 class="recipient-list">Recipient list</h2>
|
||||
<div>
|
||||
<ul class="usa-icon-list">
|
||||
<li class="usa-icon-list__item">
|
||||
<img src="{{ url_for('static', filename='img/material-icons/description.svg') }}" alt="Description Icon">
|
||||
<div class="usa-icon-list__content">
|
||||
<h3>{{ job.original_file_name }}</h3>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h2>Delivery Status</h2>
|
||||
{% endset %}
|
||||
|
||||
<div class="ajax-block-container">
|
||||
<p class='bottom-gutter'>
|
||||
{% 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 %}
|
||||
<div class="usa-alert usa-alert--info">
|
||||
<div class="usa-alert__body">
|
||||
<h4 class="usa-alert__heading">Your text has been scheduled</h4>
|
||||
<p class="usa-alert__text">
|
||||
{{ job.template_name }} - {{ current_service.name }} was scheduled on {{ job.scheduled_for|format_datetime_normal }} by {{ job.created_by.name }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{{display_message_status}}
|
||||
{% else %}
|
||||
Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short_america }}
|
||||
<div class="usa-alert usa-alert--success">
|
||||
<div class="usa-alert__body">
|
||||
<h4 class="usa-alert__heading">Your text has been sent</h4>
|
||||
<p class="usa-alert__text">
|
||||
{{ job.template_name }} - {{ current_service.name }} was sent on {{ job.created_at|format_datetime_normal }} by {{ job.created_by.name }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{{display_message_status}}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short_america }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if job.status == 'sending limits exceeded'%}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{% endcall %}
|
||||
{% if item.expiry_date %}
|
||||
{% call field(align='right') %}
|
||||
<span class='hint'>Revoked {{ item.expiry_date|format_datetime_short }}</span>
|
||||
<span class='hint'>Revoked {{ item.expiry_date|format_datetime_table }}</span>
|
||||
{% endcall %}
|
||||
{% else %}
|
||||
{% call field(align='right', status='error') %}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
{{ notification.template.name }}
|
||||
</td>
|
||||
<td class="table-field time-sent">
|
||||
{{ job.created_at | format_datetime_short_america }}
|
||||
{{ job.created_at | format_datetime_table }}
|
||||
</td>
|
||||
<td class="table-field sender">
|
||||
{{ notification.created_by.name }}
|
||||
|
||||
@@ -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 %}
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{ updates_url }}"
|
||||
data-key="status"
|
||||
data-form=""
|
||||
>
|
||||
{% endif %}
|
||||
{{ partials['status']|safe }}
|
||||
{% if not job.processing_finished %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ page_header("Message status") }}
|
||||
{{ partials['status']|safe }}
|
||||
{% if not finished %}
|
||||
<div
|
||||
data-module="update-content"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
{{ text_field(item.complaint_type) }}
|
||||
|
||||
{{ text_field(item.complaint_date|format_datetime_short if item.complaint_date else None) }}
|
||||
{{ text_field(item.complaint_date|format_datetime_table if item.complaint_date else None) }}
|
||||
|
||||
{% endcall %}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import call
|
||||
import pytest
|
||||
from flask import url_for
|
||||
|
||||
from app.formatters import format_datetime_short
|
||||
from app.formatters import format_datetime_table
|
||||
from tests import sample_uuid, validate_route_permission
|
||||
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
||||
|
||||
@@ -123,7 +123,7 @@ def test_should_show_api_keys_page(
|
||||
assert rows[0] == "API keys Action"
|
||||
assert (
|
||||
rows[1]
|
||||
== f"another key name Revoked {format_datetime_short(date.fromtimestamp(0).isoformat())}"
|
||||
== f"another key name Revoked {format_datetime_table(date.fromtimestamp(0).isoformat())}"
|
||||
)
|
||||
assert rows[2] == "some key name Revoke some key name"
|
||||
|
||||
|
||||
@@ -511,18 +511,18 @@ def test_download_inbox(
|
||||
)
|
||||
assert response.headers["Content-Type"] == ("text/csv; " "charset=utf-8")
|
||||
assert response.headers["Content-Disposition"] == (
|
||||
"inline; " 'filename="Received text messages 2016-07-01.csv"'
|
||||
"inline; " 'filename="Received text messages 07-01-2016.csv"'
|
||||
)
|
||||
assert response.get_data(as_text=True) == (
|
||||
"Phone number,Message,Received\r\n"
|
||||
"(202) 867-5300,message-1,2016-07-01 11:00 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-2,2016-07-01 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-3,2016-07-01 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5302,message-4,2016-07-01 08:59 US/Eastern\r\n"
|
||||
"+33 1 12 34 56 78,message-5,2016-07-01 06:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-6,2016-07-01 04:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-7,2016-07-01 02:59 US/Eastern\r\n"
|
||||
"+682 12345,message-8,2016-07-01 02:59 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-1,07-01-2016 11:00 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-2,07-01-2016 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-3,07-01-2016 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5302,message-4,07-01-2016 08:59 US/Eastern\r\n"
|
||||
"+33 1 12 34 56 78,message-5,07-01-2016 06:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-6,07-01-2016 04:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-7,07-01-2016 02:59 US/Eastern\r\n"
|
||||
"+682 12345,message-8,07-01-2016 02:59 US/Eastern\r\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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 01-01-2016 at 06:09 AM"
|
||||
)
|
||||
@@ -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"
|
||||
"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(
|
||||
@@ -424,8 +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 01-01-2016 at 12:00 AM" 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")
|
||||
@@ -466,8 +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 06-01-2016 at 04:00 PM" in content["status"]
|
||||
assert "12:00" in content["notifications"]
|
||||
assert "01-01-2016 at 12:00 AM" in content["notifications"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -267,10 +267,6 @@ 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
|
||||
)
|
||||
assert len(page.select("main p:nth-of-type(1) a")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -2030,7 +2030,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,
|
||||
|
||||
Reference in New Issue
Block a user