From 7881753193210f4a78f361378aa801bdc53c6d16 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 13 Jul 2017 07:09:33 +0100 Subject: [PATCH] Replace blue boxes with total + delivery estimate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sending/failed/delivered thing: - doesn’t map to the actual states of letters - doesn’t respond quickly enough to give you feedback that something is happening (because "sending" doesn’t even go to "probably delivered" for a few days) This commit replaces these 4 boxes with some more useful information: - one number – how many letters were in the job in total - when we estimate that the letters will be delivered --- app/main/views/jobs.py | 17 +++++++++++--- .../partials/jobs/count-letters.html | 23 +++++++++++++++++++ tests/app/main/views/test_jobs.py | 6 +++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 app/templates/partials/jobs/count-letters.html diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 9bc9524fb..2137e0e80 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -40,6 +40,7 @@ from app.utils import ( FAILURE_STATUSES, SENDING_STATUSES, DELIVERED_STATUSES, + get_letter_timings, ) from app.statistics_utils import add_rate_to_job @@ -353,12 +354,22 @@ def get_job_partials(job): template_id=job['template'], version=job['template_version'] )['data'] - return { - 'counts': render_template( + + if template['template_type'] == 'letter': + counts = render_template( + 'partials/jobs/count-letters.html', + total=job.get('notification_count', 0), + delivery_estimate=get_letter_timings(job['created_at']).earliest_delivery, + ) + else: + counts = render_template( 'partials/count.html', counts=_get_job_counts(job), status=filter_args['status'] - ), + ) + + return { + 'counts': counts, 'notifications': render_template( 'partials/jobs/notifications.html', notifications=list( diff --git a/app/templates/partials/jobs/count-letters.html b/app/templates/partials/jobs/count-letters.html new file mode 100644 index 000000000..7b5066038 --- /dev/null +++ b/app/templates/partials/jobs/count-letters.html @@ -0,0 +1,23 @@ +{% from 'components/big-number.html' import big_number %} +{% from 'components/message-count-label.html' import message_count_label %} + +
+
+
+ {{ big_number( + total, + message_count_label(total, 'letter', suffix='')|capitalize, + smaller=True + )}} +
+
+
+
+ {{ big_number( + delivery_estimate|string|format_date_short, + 'Estimated delivery date', + smaller=True + )}} +
+
+
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 109de4e2f..0f9bca59e 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -177,6 +177,12 @@ def test_should_show_letter_job( assert normalize_spaces(page.select('tbody tr')[0].text) == ( '07123456789 template content' ) + assert normalize_spaces(page.select('.keyline-block')[0].text) == ( + '1 Letter' + ) + assert normalize_spaces(page.select('.keyline-block')[1].text) == ( + '6 January Estimated delivery date' + ) mock_get_notifications.assert_called_with( SERVICE_ONE_ID,