Add a link to reject a broadcast

If a broadcast definitely shouldn’t go out (for example because it has a
spelling mistake or is going to the wrong areas) then we should have a
way of removing it. Once it’s removed no-one else can approve it, and it
isn’t cluttering up the dashboard.

This is a link (because it’s a secondary action) and red (because it’s
destructive, in that it’s throwing away someone’s work).
This commit is contained in:
Chris Hill-Scott
2020-07-17 08:07:44 +01:00
parent a99b40304b
commit 03b4aabf5f
6 changed files with 134 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
line-height: 40px;
padding: 1px 0 0 15px;
font-weight: normal;
}

View File

@@ -195,6 +195,31 @@ def approve_broadcast_message(service_id, broadcast_message_id):
))
@main.route('/services/<uuid:service_id>/broadcast/<uuid:broadcast_message_id>/reject')
@user_has_permissions('send_messages')
@service_has_permission('broadcast')
def reject_broadcast_message(service_id, broadcast_message_id):
broadcast_message = BroadcastMessage.from_id(
broadcast_message_id,
service_id=current_service.id,
)
if broadcast_message.status != 'pending-approval':
return redirect(url_for(
'.view_broadcast_message',
service_id=current_service.id,
broadcast_message_id=broadcast_message.id,
))
broadcast_message.reject_broadcast()
return redirect(url_for(
'.broadcast_dashboard',
service_id=current_service.id,
))
@main.route('/services/<uuid:service_id>/broadcast/<uuid:broadcast_message_id>/cancel')
@user_has_permissions('send_messages')
@service_has_permission('broadcast')

View File

@@ -144,6 +144,9 @@ class BroadcastMessage(JSONModel):
)
self._set_status_to('broadcasting')
def reject_broadcast(self):
self._set_status_to('rejected')
def cancel_broadcast(self):
self._set_status_to('cancelled')

View File

@@ -362,6 +362,7 @@ class HeaderNavigation(Navigation):
'preview_broadcast_message',
'view_broadcast_message',
'approve_broadcast_message',
'reject_broadcast_message',
'cancel_broadcast_message',
}
@@ -421,6 +422,7 @@ class MainNavigation(Navigation):
'preview_broadcast_message',
'view_broadcast_message',
'approve_broadcast_message',
'reject_broadcast_message',
'cancel_broadcast_message',
},
'uploads': {
@@ -1015,6 +1017,7 @@ class CaseworkNavigation(Navigation):
'preview_broadcast_message',
'view_broadcast_message',
'approve_broadcast_message',
'reject_broadcast_message',
'cancel_broadcast_message',
}
@@ -1337,5 +1340,6 @@ class OrgNavigation(Navigation):
'preview_broadcast_message',
'view_broadcast_message',
'approve_broadcast_message',
'reject_broadcast_message',
'cancel_broadcast_message',
}

View File

@@ -23,7 +23,9 @@
message until {{ broadcast_message.finishes_at|format_datetime_relative }}.
</p>
{{ page_footer(
"Start broadcasting now"
"Start broadcasting now",
delete_link=url_for('main.reject_broadcast_message', service_id=current_service.id, broadcast_message_id=broadcast_message.id),
delete_link_text='Reject this broadcast'
) }}
{% endcall %}
{% else %}