diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 2137e0e80..d34b9ac1e 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -110,6 +110,13 @@ def view_job(service_id, job_id): total_notifications = job.get('notification_count', 0) processed_notifications = job.get('notifications_delivered', 0) + job.get('notifications_failed', 0) + + template = service_api_client.get_service_template( + service_id=service_id, + template_id=job['template'], + version=job['template_version'] + )['data'] + return render_template( 'views/jobs/job.html', finished=(total_notifications == processed_notifications), @@ -122,7 +129,11 @@ def view_job(service_id, job_id): job_id=job['id'], status=request.args.get('status', ''), ), - partials=get_job_partials(job), + partials=get_job_partials(job, template), + just_sent=bool( + request.args.get('just_sent') == 'yes' and + template['template_type'] == 'letter' + ) ) @@ -171,8 +182,16 @@ def cancel_job(service_id, job_id): @main.route("/services//jobs/.json") @user_has_permissions('view_activity', admin_override=True) def view_job_updates(service_id, job_id): + + job = job_api_client.get_job(service_id, job_id)['data'] + return jsonify(**get_job_partials( - job_api_client.get_job(service_id, job_id)['data'] + job, + service_api_client.get_service_template( + service_id=current_service['id'], + template_id=job['template'], + version=job['template_version'] + )['data'], )) @@ -343,17 +362,12 @@ def _get_job_counts(job): ] -def get_job_partials(job): +def get_job_partials(job, template): filter_args = _parse_filter_args(request.args) filter_args['status'] = _set_status_filters(filter_args) notifications = notification_api_client.get_notifications_for_service( job['service'], job['id'], status=filter_args['status'] ) - template = service_api_client.get_service_template( - service_id=current_service['id'], - template_id=job['template'], - version=job['template_version'] - )['data'] if template['template_type'] == 'letter': counts = render_template( diff --git a/app/main/views/send.py b/app/main/views/send.py index 8b72c3b9a..31dc37584 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -499,7 +499,13 @@ def start_job(service_id, upload_id): ) return redirect( - url_for('main.view_job', job_id=upload_id, service_id=service_id, help=request.form.get('help')) + url_for( + 'main.view_job', + job_id=upload_id, + service_id=service_id, + help=request.form.get('help'), + just_sent='yes', + ) ) diff --git a/app/templates/views/jobs/job.html b/app/templates/views/jobs/job.html index 45d0b8892..9b8eccf32 100644 --- a/app/templates/views/jobs/job.html +++ b/app/templates/views/jobs/job.html @@ -13,7 +13,11 @@ {{ uploaded_file_name }} - {{ ajax_block(partials, updates_url, 'status', finished=finished) }} + {% if just_sent %} + {{ banner('We’ve started printing your letters', type='default', with_tick=True) }} + {% else %} + {{ ajax_block(partials, updates_url, 'status', finished=finished) }} + {% endif %} {{ ajax_block(partials, updates_url, 'counts', finished=finished) }} {{ ajax_block(partials, updates_url, 'notifications', finished=finished) }} diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 20251d271..1059e0792 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -174,6 +174,10 @@ def test_should_show_letter_job( ) assert normalize_spaces(page.h1.text) == 'thisisatest.csv' + assert normalize_spaces(page.select('p.bottom-gutter')[0].text) == ( + 'Sent by Test User on 1 January at 11:09am' + ) + assert page.select('.banner-default-with-tick') == [] assert normalize_spaces(page.select('tbody tr')[0].text) == ( '07123456789 template content' ) @@ -203,6 +207,28 @@ def test_should_show_letter_job( ) +@freeze_time("2016-01-01 11:09:00.061258") +def test_should_show_letter_job_with_banner_after_sending( + client_request, + mock_get_service_letter_template, + mock_get_job, + mock_get_notifications, + fake_uuid, +): + + page = client_request.get( + 'main.view_job', + service_id=SERVICE_ONE_ID, + job_id=fake_uuid, + just_sent='yes', + ) + + assert page.select('p.bottom-gutter') == [] + assert normalize_spaces(page.select('.banner-default-with-tick')[0].text) == ( + 'We’ve started printing your letters' + ) + + @freeze_time("2016-01-01T00:00:00.061258") def test_should_show_scheduled_job( logged_in_client, diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 30c7eb244..6b23f5d02 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -1144,6 +1144,7 @@ def test_can_start_letters_job( data={} ) assert response.status_code == 302 + assert 'just_sent=yes' in response.location @pytest.mark.parametrize('filetype', ['pdf', 'png'])