Merge pull request #3235 from alphagov/job-page-for-expired-jobs

Customise the job page for jobs whose notifications have been purged
This commit is contained in:
Chris Hill-Scott
2020-01-09 09:46:19 +00:00
committed by GitHub
5 changed files with 81 additions and 7 deletions
+5 -1
View File
@@ -446,7 +446,10 @@ def get_job_partials(job, template):
counts = render_template( counts = render_template(
'partials/count.html', 'partials/count.html',
counts=_get_job_counts(job), counts=_get_job_counts(job),
status=filter_args['status'] status=filter_args['status'],
notifications_deleted=(
job['job_status'] == 'finished' and not notifications['notifications']
),
) )
service_data_retention_days = current_service.get_days_of_retention(template['template_type']) service_data_retention_days = current_service.get_days_of_retention(template['template_type'])
can_letter_job_be_cancelled = False can_letter_job_be_cancelled = False
@@ -480,6 +483,7 @@ def get_job_partials(job, template):
job=job, job=job,
template=template, template=template,
template_version=job['template_version'], template_version=job['template_version'],
service_data_retention_days=service_data_retention_days,
), ),
'status': render_template( 'status': render_template(
'partials/jobs/status.html', 'partials/jobs/status.html',
+15 -2
View File
@@ -1,5 +1,18 @@
{% from "components/big-number.html" import big_number %}
{% from "components/pill.html" import pill %} {% from "components/pill.html" import pill %}
<div class="bottom-gutter ajax-block-container"> <div class="ajax-block-container">
{{ pill(counts, request.args.get('status', '')) }} {% if notifications_deleted %}
<div class="grid-row bottom-gutter-1-2">
{% for label, query_param, url, count in counts %}
<div class="column-one-quarter">
{{ big_number(count, label, smaller=True) }}
</div>
{% endfor %}
</div>
{% else %}
<div class="bottom-gutter">
{{ pill(counts, request.args.get('status', '')) }}
</div>
{% endif %}
</div> </div>
@@ -28,7 +28,7 @@
{% if template.template_type == 'letter' %} {% if template.template_type == 'letter' %}
<div class="keyline-block bottom-gutter-1-2"> <div class="keyline-block bottom-gutter-1-2">
{% endif %} {% endif %}
{% if percentage_complete < 100 %} {% if percentage_complete < 100 and job.job_status != 'finished' %}
<p class="{% if template.template_type != 'letter' %}bottom-gutter{% endif %} hint"> <p class="{% if template.template_type != 'letter' %}bottom-gutter{% endif %} hint">
Report is {{ "{:.0f}%".format(percentage_complete * 0.99) }} complete… Report is {{ "{:.0f}%".format(percentage_complete * 0.99) }} complete…
</p> </p>
@@ -47,7 +47,7 @@
notifications, notifications,
caption=uploaded_file_name, caption=uploaded_file_name,
caption_visible=False, caption_visible=False,
empty_message="No messages to show", empty_message='These messages have been deleted because they were sent more than {} days ago'.format(service_data_retention_days) if job.job_status == 'finished' else 'No messages to show yet…',
field_headings=[ field_headings=[
'Recipient', 'Recipient',
'Status' 'Status'
+57 -1
View File
@@ -294,7 +294,63 @@ def test_should_show_job_in_progress(
service_id=service_one['id'], service_id=service_one['id'],
job_id=fake_uuid, job_id=fake_uuid,
) )
assert page.find('p', {'class': 'hint'}).text.strip() == 'Report is 50% complete…' assert [
normalize_spaces(link.text)
for link in page.select('.pill a')
] == [
'10 sending', '0 delivered', '0 failed'
]
assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…'
def test_should_show_job_without_notifications(
client_request,
service_one,
active_user_with_permissions,
mock_get_service_template,
mock_get_job_in_progress,
mocker,
mock_get_notifications_with_no_notifications,
mock_get_service_data_retention,
fake_uuid,
):
page = client_request.get(
'main.view_job',
service_id=service_one['id'],
job_id=fake_uuid,
)
assert [
normalize_spaces(link.text)
for link in page.select('.pill a')
] == [
'10 sending', '0 delivered', '0 failed'
]
assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…'
assert page.select_one('tbody').text.strip() == 'No messages to show yet…'
def test_should_show_old_job(
client_request,
service_one,
active_user_with_permissions,
mock_get_service_template,
mock_get_job,
mocker,
mock_get_notifications_with_no_notifications,
mock_get_service_data_retention,
fake_uuid,
):
page = client_request.get(
'main.view_job',
service_id=service_one['id'],
job_id=fake_uuid,
)
assert not page.select('.pill a')
assert not page.select('p.hint')
assert not page.select('a[download]')
assert page.select_one('tbody').text.strip() == (
'These messages have been deleted because they were sent more than 7 days ago'
)
@freeze_time("2016-01-01 11:09:00.061258") @freeze_time("2016-01-01 11:09:00.061258")
+2 -1
View File
@@ -1818,7 +1818,8 @@ def mock_get_job_in_progress(mocker, api_user_active):
return {"data": job_json( return {"data": job_json(
service_id, api_user_active, job_id=job_id, service_id, api_user_active, job_id=job_id,
notification_count=10, notification_count=10,
notifications_requested=5 notifications_requested=5,
job_status='processing',
)} )}
return mocker.patch('app.job_api_client.get_job', side_effect=_get_job) return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)