From 5b83db97688b09e0f84d3b17f357b51185d09e37 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 17 Jul 2020 08:07:43 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20start=20broadcasts=20immediatel?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t want one person going full yolo and start broadcasting without any oversight. This commit changes the flow so that the button on the ‘preview’ page puts the broadcast into `pending-approval`, rather than directly into `broadcasting`. --- app/main/views/broadcast.py | 2 +- app/models/broadcast_message.py | 5 ++--- app/templates/views/broadcast/preview-message.html | 2 +- tests/app/main/views/test_broadcast.py | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/main/views/broadcast.py b/app/main/views/broadcast.py index 1737dbb8f..956db3b5b 100644 --- a/app/main/views/broadcast.py +++ b/app/main/views/broadcast.py @@ -142,7 +142,7 @@ def preview_broadcast_message(service_id, broadcast_message_id): service_id=current_service.id, ) if request.method == 'POST': - broadcast_message.start_broadcast() + broadcast_message.request_approval() return redirect(url_for( '.broadcast_dashboard', service_id=current_service.id, diff --git a/app/models/broadcast_message.py b/app/models/broadcast_message.py index 189e1d9e1..27898ee92 100644 --- a/app/models/broadcast_message.py +++ b/app/models/broadcast_message.py @@ -132,12 +132,11 @@ class BroadcastMessage(JSONModel): data=kwargs, ) - def start_broadcast(self): + def request_approval(self): self._update( - starts_at=datetime.utcnow().isoformat(), finishes_at=(datetime.utcnow() + self.DEFAULT_TTL).isoformat(), ) - self._set_status_to('broadcasting') + self._set_status_to('pending-approval') def cancel_broadcast(self): self._set_status_to('cancelled') diff --git a/app/templates/views/broadcast/preview-message.html b/app/templates/views/broadcast/preview-message.html index f37537b1f..bed3cae07 100644 --- a/app/templates/views/broadcast/preview-message.html +++ b/app/templates/views/broadcast/preview-message.html @@ -28,7 +28,7 @@ {{ broadcast_message.template|string }} {% call form_wrapper() %} - {{ sticky_page_footer('Start broadcast') }} + {{ sticky_page_footer('Submit for approval') }} {% endcall %} {% endblock %} diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py index d777b9002..e306a30be 100644 --- a/tests/app/main/views/test_broadcast.py +++ b/tests/app/main/views/test_broadcast.py @@ -313,12 +313,11 @@ def test_start_broadcasting( service_id=SERVICE_ONE_ID, broadcast_message_id=fake_uuid, data={ - 'starts_at': '2020-02-02T02:02:02.222222', 'finishes_at': '2020-02-05T02:02:02.222222', }, ) mock_update_broadcast_message_status.assert_called_once_with( - 'broadcasting', + 'pending-approval', service_id=SERVICE_ONE_ID, broadcast_message_id=fake_uuid, )