From 0bdd5cab2d79e02802ff6ab24f03c418fbac2ea6 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 12 Feb 2021 18:03:29 +0000 Subject: [PATCH] =?UTF-8?q?Show=20rejected=20broadcasts=20on=20=E2=80=98Pr?= =?UTF-8?q?evious=20alerts=E2=80=99=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two reasons to not hide rejected broadcasts: - if a broadcast was rejected by mistake then it’s useful to have an audit of who did that - it means you can still see old broadcasts without having to leave in pending-approval, which is dangerous because they might accidentally be approved --- app/main/views/broadcast.py | 6 +++++- .../views/broadcast/partials/dashboard-table.html | 4 ++++ tests/app/main/views/test_broadcast.py | 1 + tests/conftest.py | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/main/views/broadcast.py b/app/main/views/broadcast.py index 512b3fbb2..656b308ae 100644 --- a/app/main/views/broadcast.py +++ b/app/main/views/broadcast.py @@ -48,7 +48,11 @@ def broadcast_dashboard(service_id): def broadcast_dashboard_previous(service_id): return render_template( 'views/broadcast/previous-broadcasts.html', - broadcasts=BroadcastMessages(service_id).with_status('cancelled', 'completed'), + broadcasts=BroadcastMessages(service_id).with_status( + 'cancelled', + 'completed', + 'rejected', + ), empty_message='You do not have any previous alerts', view_broadcast_endpoint='.view_previous_broadcast', ) diff --git a/app/templates/views/broadcast/partials/dashboard-table.html b/app/templates/views/broadcast/partials/dashboard-table.html index a0d7fef5b..eb8a6d23f 100644 --- a/app/templates/views/broadcast/partials/dashboard-table.html +++ b/app/templates/views/broadcast/partials/dashboard-table.html @@ -18,6 +18,10 @@

Waiting for approval

+ {% elif item.status == 'rejected' %} +

+ Rejected {{ item.updated_at|format_datetime_relative }} +

{% elif item.status == 'broadcasting' %}

Live since {{ item.starts_at|format_datetime_relative }} diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py index 2fa9a5140..3272bb700 100644 --- a/tests/app/main/views/test_broadcast.py +++ b/tests/app/main/views/test_broadcast.py @@ -420,6 +420,7 @@ def test_previous_broadcasts_page( normalize_spaces(row.text) for row in page.select('.ajax-block-container')[0].select('.file-list') ] == [ + 'Example template This is a test Rejected today at 1:20am England Scotland', 'Example template This is a test Broadcast yesterday at 2:20pm England Scotland', 'Example template This is a test Broadcast yesterday at 2:20am England Scotland', ] diff --git a/tests/conftest.py b/tests/conftest.py index aaea67a89..ba4ba6527 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4420,6 +4420,13 @@ def mock_get_broadcast_messages( datetime.utcnow() - timedelta(days=10) ).isoformat(), ), + partial_json( + id_=uuid4(), + status='rejected', + updated_at=( + datetime.utcnow() - timedelta(hours=1) + ).isoformat(), + ), ] return mocker.patch(