diff --git a/app/__init__.py b/app/__init__.py index 4d68a06541..f81f330ac9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -496,8 +496,8 @@ def _getStatusByBounceSubtype(): def format_notification_status_as_time(status, created, updated): return dict.fromkeys( {"created", "pending", "sending"}, - " " + _("since") + ' {}'.format(created), - ).get(status, '{}'.format(updated)) + " " + _("since") + ' '.format(created), + ).get(status, ''.format(updated)) def format_notification_status_as_field_status(status, notification_type): diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index eea5436e66..5fd724c719 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -1,37 +1,44 @@ window.formatAllDates = function () { $(".local-datetime-short").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleString(locale, { - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", - }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleString(locale, { + month: "short", + day: "numeric", + hour: "numeric", + minute: "2-digit", + }), + ); } }); $(".local-datetime-short-year").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleString(locale, { - month: "short", - day: "numeric", - year: "numeric", - }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleString(locale, { + month: "short", + day: "numeric", + year: "numeric", + }), + ); } }); $(".local-datetime-full").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if ($(this).text().trim() === "None") { @@ -39,31 +46,34 @@ window.formatAllDates = function () { } if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleDateString(locale, { dateStyle: "long" }) + - ", " + - datetime.toLocaleTimeString(locale, { timeStyle: "short" }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleDateString(locale, { dateStyle: "long" }) + + ", " + + datetime.toLocaleTimeString(locale, { timeStyle: "short" }), + ); } }); $(".relative-time-past").each(function (index) { - let timeRaw = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date($(this).text().trim()); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; - let time = moment(timeRaw); + let time = moment(datetime); if (time.isValid() && window.APP_LANG) { let isToday = moment().isSame(time, "day"); let dayStr = ""; - let timeStr = timeRaw.toLocaleTimeString(locale, { timeStyle: "short" }); + let timeStr = datetime.toLocaleTimeString(locale, { timeStyle: "short" }); if (isToday && window.APP_PHRASES) { dayStr = window.APP_PHRASES["today"]; } else { - dayStr = timeRaw.toLocaleDateString(locale, { dateStyle: "long" }); + dayStr = datetime.toLocaleDateString(locale, { dateStyle: "long" }); } - $(this).text(`${dayStr}, ${timeStr}`); + $(this).attr("datetime", datetimeRaw).text(`${dayStr}, ${timeStr}`); } }); }; diff --git a/app/templates/partials/jobs/notifications_header.html b/app/templates/partials/jobs/notifications_header.html index bb018402bf..41db71674c 100644 --- a/app/templates/partials/jobs/notifications_header.html +++ b/app/templates/partials/jobs/notifications_header.html @@ -24,7 +24,7 @@ {% else %} {{ _('Download this report') }}
- {{ _("Available until") }} {{ available_until_date }} + {{ _("Available until") }}
{% endif %} diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 45d01be11f..07a5fa6967 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -12,7 +12,7 @@
{{ _('Started:') }} - {{ job.created_at }} +
{% if job.api_key %} diff --git a/app/templates/views/api/index.html b/app/templates/views/api/index.html index 1ec0ad7976..27e87e8d64 100644 --- a/app/templates/views/api/index.html +++ b/app/templates/views/api/index.html @@ -99,7 +99,7 @@

] %} {% if notification[key] %}
{{ key }}:
-
{{ notification[key] }}
+
{% endif %} {% endfor %} {% if notification.status not in ('pending-virus-check', 'virus-scan-failed') %} diff --git a/app/templates/views/api/keys.html b/app/templates/views/api/keys.html index 07d28ea94a..a3b5538eb3 100644 --- a/app/templates/views/api/keys.html +++ b/app/templates/views/api/keys.html @@ -64,19 +64,19 @@

{% endif %}

- {{ _('Created:') }} {{ item.created_at }} + {{ _('Created:') }}
- {{ _('Expires:') }} {{ item.expiry_date }} + {{ _('Expires:') }}
- {{ _('Last used:') }} {{ item.last_send }} + {{ _('Last used:') }}
{% endcall %} {% if item.expiry_date %} {% call field(align='right') %} - {{ _('Revoked') }} {{ item.expiry_date }} + {{ _('Revoked') }} {% endcall %} {% else %} {% call field(align='right', status='error') %} diff --git a/app/templates/views/dashboard/_jobs.html b/app/templates/views/dashboard/_jobs.html index 2b6aa97165..c26d07594b 100644 --- a/app/templates/views/dashboard/_jobs.html +++ b/app/templates/views/dashboard/_jobs.html @@ -22,9 +22,9 @@ {{ item.original_file_name }} {{ _('Sent') }} - + + {% endcall %} diff --git a/app/templates/views/dashboard/_upcoming.html b/app/templates/views/dashboard/_upcoming.html index 59976c020e..1600008b5f 100644 --- a/app/templates/views/dashboard/_upcoming.html +++ b/app/templates/views/dashboard/_upcoming.html @@ -20,7 +20,7 @@
{{ item.original_file_name }} - {{ _("Starting") }} {{ item.scheduled_for }} + {{ _("Starting") }}
{% endcall %} diff --git a/app/templates/views/jobs/job.html b/app/templates/views/jobs/job.html index 5d52091d96..d3d8677f84 100644 --- a/app/templates/views/jobs/job.html +++ b/app/templates/views/jobs/job.html @@ -35,7 +35,7 @@

{{ _('Scheduled for') }}
- {{ job.scheduled_for }} +
{% if job.api_key %} @@ -82,7 +82,7 @@

{% else %} {{ empty_list( - _("GC Notify disposed of the information in this report on {}").format(job.updated_at), + _("GC Notify disposed of the information in this report on ").format(job.updated_at), _('After {} days, we keep only non-identifying statistics.').format(svc_retention_days), 'emptyBirdHole' ) diff --git a/app/templates/views/login_events.html b/app/templates/views/login_events.html index def150006d..32baacdcd0 100644 --- a/app/templates/views/login_events.html +++ b/app/templates/views/login_events.html @@ -17,7 +17,7 @@

{{ _('Sign-in history') }}

- {{ event.created_at }} + diff --git a/app/templates/views/notifications/invalid_precompiled_letter.html b/app/templates/views/notifications/invalid_precompiled_letter.html index b0be8c5ad3..ce0dc7d7de 100644 --- a/app/templates/views/notifications/invalid_precompiled_letter.html +++ b/app/templates/views/notifications/invalid_precompiled_letter.html @@ -9,7 +9,7 @@

Letter

- Provided as PDF on {{ created_at }} + Provided as PDF on

Validation failed – this isn’t a PDF file that Notification can read diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 695c970beb..555de52462 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -44,14 +44,14 @@ {% elif created_by %} {{ _('by') }} {{ created_by.name }} {% endif %} - {{ _('on') }} {{ created_at }} + {{ _('on') }}

{% if template.template_type == 'letter' %} {% if notification_status in ('permanent-failure', 'cancelled') %}

- Cancelled {{ updated_at }} + Cancelled

{% elif notification_status == 'validation-failed' %}

diff --git a/app/templates/views/platform-admin/complaints.html b/app/templates/views/platform-admin/complaints.html index 97dd813a27..750399ee7d 100644 --- a/app/templates/views/platform-admin/complaints.html +++ b/app/templates/views/platform-admin/complaints.html @@ -29,7 +29,7 @@

{{ text_field(item.complaint_type) }} - {{ text_field(item.complaint_date if item.complaint_date else None) }} + {% endcall %} diff --git a/app/templates/views/providers/provider.html b/app/templates/views/providers/provider.html index 13dbba3473..dea253a345 100644 --- a/app/templates/views/providers/provider.html +++ b/app/templates/views/providers/provider.html @@ -29,7 +29,7 @@ {{ text_field(item.version) }} {% if item.updated_at %} - {{ text_field(item.updated_at) }} + {% else %} {{ text_field('None') }} {% endif %} diff --git a/app/templates/views/providers/providers.html b/app/templates/views/providers/providers.html index a86fe2b288..cc990071d7 100644 --- a/app/templates/views/providers/providers.html +++ b/app/templates/views/providers/providers.html @@ -30,7 +30,7 @@

SMS

{{ text_field(item.active) }} {% if item.updated_at %} - {{ text_field(item.updated_at) }} + {% else %} {{ text_field('None') }} {% endif %} @@ -59,7 +59,7 @@

Email

{{ text_field(item.active) }} {% if item.updated_at %} - {{ text_field(item.updated_at) }} + {% else %} {{ text_field('None') }} {% endif %} @@ -88,7 +88,7 @@

International SMS Providers

{{ text_field(item.active) }} {% if item.updated_at %} - {{ text_field(item.updated_at) }} + {% else %} {{ text_field('None') }} {% endif %} diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 7755bec44b..e1d871dfac 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -3,7 +3,7 @@
{% if template._template.archived %}

- {{ _('This template was deleted') }} {{ template._template.updated_at }}. + {{ _('This template was deleted') }} .

{% elif not current_user.has_permissions('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') or not user_has_template_permission %}

diff --git a/app/templates/views/templates/_template_history.html b/app/templates/views/templates/_template_history.html index 1bc33b516d..f6423687cf 100644 --- a/app/templates/views/templates/_template_history.html +++ b/app/templates/views/templates/_template_history.html @@ -7,10 +7,10 @@

{{ template.name }}

{{ _("Version {}").format(template.get_raw('version', 1)) }}{{ _(": ")}} {% endif %} {% if template.get_raw('version', 1) > 1 %} - {{ _('Edit made') }} {% if template.get_raw('updated_at', None) %}{{ template.get_raw('updated_at') }}{% endif %} + {{ _('Edit made') }} {% if template.get_raw('updated_at', None) %}{% endif %} {% else %} {{ _('Created') }} - {% if template.get_raw('created_at', None) %}{{ template.get_raw('created_at') }}{% endif %} + {% if template.get_raw('created_at', None) %}{% endif %} {% endif %} {{ _('by') }} {{ template.get_raw('created_by').name }}

diff --git a/app/translations/csv/fr.csv b/app/translations/csv/fr.csv index 8d89b82740..5a48c5a6ad 100644 --- a/app/translations/csv/fr.csv +++ b/app/translations/csv/fr.csv @@ -1794,7 +1794,7 @@ "Started:","Début :" "Spreadsheet:","Feuille de calcul :" "API request name:","Nom de la requête API :" -"GC Notify disposed of the information in this report on {}","Notification GC a supprimé les renseignements de ce rapport le {}" +"GC Notify disposed of the information in this report on ","Notification GC a supprimé les renseignements de ce rapport le " "After {} days, we keep only non-identifying statistics.","Après {} jours, nous ne conservons que des statistiques anonymes qui ne permettent pas d’identifier les destinataires." "{} is not on our list of government domains. If it’s a government email address, {}.","{} ne figure pas sur notre liste de domaines gouvernementaux. S’il s’agit d’une adresse courriel gouvernementale, {}." "System status","État du système" diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 3a72713754..d3a488c7e8 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -202,7 +202,7 @@ def test_should_show_page_for_one_job( status=status_argument, ) assert csv_link.text == "Download this report" - assert page.find("span", {"id": "time-left"}).text.split(" ")[0] == "2016-01-09" + assert page.find("time", {"id": "time-left"}).text.split(" ")[0] == "2016-01-09" assert normalize_spaces(page.select_one("tbody tr").text) == normalize_spaces( "6502532222 " "template content " "No " "Delivered 11:10:00.061258" @@ -231,7 +231,7 @@ def test_should_show_page_for_one_job_with_flexible_data_retention( mock_get_service_data_retention.side_effect = [[{"days_of_retention": 10, "notification_type": "sms"}]] page = client_request.get("main.view_job", service_id=SERVICE_ONE_ID, job_id=fake_uuid, status="delivered") - assert page.find("span", {"id": "time-left"}).text.split(" ")[0] == "2016-01-12" + assert page.find("time", {"id": "time-left"}).text.split(" ")[0] == "2016-01-12" assert "Cancel sending these letters" not in page