mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Make ‘Available for…’ text on job page relative
When we say ‘delivery information is available for 7 days’ you have to infer _when_ the seven days starts. When you come back to the page it still says ‘available for 7 days’ even if you only have a day left to download it. This is confusing. This commit changes the text to be relative to now, eg ‘available for 7 days’, ‘available for 1 day’. The date is counted to midnight on the seventh day, which is when the data is actually deleted.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import dateutil
|
||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
import ago
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
render_template,
|
render_template,
|
||||||
@@ -296,7 +299,6 @@ def _get_job_counts(job, help_argument):
|
|||||||
|
|
||||||
|
|
||||||
def get_job_partials(job):
|
def get_job_partials(job):
|
||||||
|
|
||||||
filter_args = _parse_filter_args(request.args)
|
filter_args = _parse_filter_args(request.args)
|
||||||
_set_status_filters(filter_args)
|
_set_status_filters(filter_args)
|
||||||
return {
|
return {
|
||||||
@@ -317,7 +319,17 @@ def get_job_partials(job):
|
|||||||
job_id=job['id'],
|
job_id=job['id'],
|
||||||
status=request.args.get('status', '')
|
status=request.args.get('status', '')
|
||||||
),
|
),
|
||||||
help=get_help_argument()
|
help=get_help_argument(),
|
||||||
|
time_left=ago.human(
|
||||||
|
(
|
||||||
|
datetime.now(timezone.utc).replace(hour=23, minute=59, second=59)
|
||||||
|
) - (
|
||||||
|
dateutil.parser.parse(job['created_at']) + timedelta(days=8)
|
||||||
|
),
|
||||||
|
future_tense='Data available for {}',
|
||||||
|
past_tense='Was available {} ago', # No-one should ever see this
|
||||||
|
precision=1
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'status': render_template(
|
'status': render_template(
|
||||||
'partials/jobs/status.html',
|
'partials/jobs/status.html',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<p class="bottom-gutter">
|
<p class="bottom-gutter">
|
||||||
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
||||||
 
|
 
|
||||||
<span id="time-left">Available for 7 days</span>
|
<span id="time-left">{{ time_left }}</span>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
ago==0.0.8
|
||||||
Flask==0.10.1
|
Flask==0.10.1
|
||||||
Flask-Script==2.0.5
|
Flask-Script==2.0.5
|
||||||
Flask-WTF==0.11
|
Flask-WTF==0.11
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timedelta, date
|
from datetime import datetime, timedelta, date, timezone
|
||||||
from flask.testing import FlaskClient
|
from flask.testing import FlaskClient
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from flask_login import login_user
|
from flask_login import login_user
|
||||||
@@ -155,7 +155,7 @@ def job_json(service_id,
|
|||||||
if template_id is None:
|
if template_id is None:
|
||||||
template_id = str(generate_uuid())
|
template_id = str(generate_uuid())
|
||||||
if created_at is None:
|
if created_at is None:
|
||||||
created_at = str(datetime.utcnow().time())
|
created_at = str(datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%f%z'))
|
||||||
if status is None:
|
if status is None:
|
||||||
status = 'Delivered'
|
status = 'Delivered'
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ def test_should_show_page_for_one_job(
|
|||||||
status=status_argument
|
status=status_argument
|
||||||
)
|
)
|
||||||
assert csv_link.text == 'Download this report'
|
assert csv_link.text == 'Download this report'
|
||||||
assert page.find('span', {'id': 'time-left'}).text == 'Available for 7 days'
|
assert page.find('span', {'id': 'time-left'}).text == 'Data available for 7 days'
|
||||||
mock_get_notifications.assert_called_with(
|
mock_get_notifications.assert_called_with(
|
||||||
service_one['id'],
|
service_one['id'],
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user