mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Add button to approve broadcast
Since new broadcasts will go into `pending-approval`, we now need a way of approving them. This commit adds a button to this page to start (or approve) the broadcast. This button is wrapped in a bordered box, to emphasise that it’s something consequential.
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
@include copy-19;
|
||||
}
|
||||
|
||||
.page-footer {
|
||||
margin-bottom: govuk-spacing(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%banner-with-tick,
|
||||
|
||||
@@ -169,6 +169,32 @@ def view_broadcast_message(service_id, broadcast_message_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/broadcast/<uuid:broadcast_message_id>', methods=['POST'])
|
||||
@user_has_permissions('send_messages')
|
||||
@service_has_permission('broadcast')
|
||||
def approve_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.approve_broadcast()
|
||||
|
||||
return redirect(url_for(
|
||||
'.view_broadcast_message',
|
||||
service_id=current_service.id,
|
||||
broadcast_message_id=broadcast_message.id,
|
||||
))
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/broadcast/<uuid:broadcast_message_id>/cancel')
|
||||
@user_has_permissions('send_messages')
|
||||
@service_has_permission('broadcast')
|
||||
|
||||
@@ -138,6 +138,12 @@ class BroadcastMessage(JSONModel):
|
||||
)
|
||||
self._set_status_to('pending-approval')
|
||||
|
||||
def approve_broadcast(self):
|
||||
self._update(
|
||||
starts_at=datetime.utcnow().isoformat(),
|
||||
)
|
||||
self._set_status_to('broadcasting')
|
||||
|
||||
def cancel_broadcast(self):
|
||||
self._set_status_to('cancelled')
|
||||
|
||||
|
||||
@@ -361,6 +361,7 @@ class HeaderNavigation(Navigation):
|
||||
'remove_broadcast_area',
|
||||
'preview_broadcast_message',
|
||||
'view_broadcast_message',
|
||||
'approve_broadcast_message',
|
||||
'cancel_broadcast_message',
|
||||
}
|
||||
|
||||
@@ -419,6 +420,7 @@ class MainNavigation(Navigation):
|
||||
'remove_broadcast_area',
|
||||
'preview_broadcast_message',
|
||||
'view_broadcast_message',
|
||||
'approve_broadcast_message',
|
||||
'cancel_broadcast_message',
|
||||
},
|
||||
'uploads': {
|
||||
@@ -1012,6 +1014,7 @@ class CaseworkNavigation(Navigation):
|
||||
'remove_broadcast_area',
|
||||
'preview_broadcast_message',
|
||||
'view_broadcast_message',
|
||||
'approve_broadcast_message',
|
||||
'cancel_broadcast_message',
|
||||
}
|
||||
|
||||
@@ -1333,5 +1336,6 @@ class OrgNavigation(Navigation):
|
||||
'remove_broadcast_area',
|
||||
'preview_broadcast_message',
|
||||
'view_broadcast_message',
|
||||
'approve_broadcast_message',
|
||||
'cancel_broadcast_message',
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% from "components/button/macro.njk" import govukButton %}
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
{% from "components/page-header.html" import page_header %}
|
||||
{% from "components/page-footer.html" import sticky_page_footer %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% extends "withnav_template.html" %}
|
||||
|
||||
@@ -17,10 +17,15 @@
|
||||
) }}
|
||||
|
||||
{% if broadcast_message.status == 'pending-approval' %}
|
||||
<p class="govuk-body govuk-!-margin-bottom-3">
|
||||
{{ broadcast_message.created_by.name }} wants to broadcast this
|
||||
message until {{ broadcast_message.finishes_at|format_datetime_relative }}.
|
||||
</p>
|
||||
{% call form_wrapper(class="banner govuk-!-margin-bottom-6") %}
|
||||
<p class="govuk-body govuk-!-margin-top-0 govuk-!-margin-bottom-3">
|
||||
{{ broadcast_message.created_by.name }} wants to broadcast this
|
||||
message until {{ broadcast_message.finishes_at|format_datetime_relative }}.
|
||||
</p>
|
||||
{{ page_footer(
|
||||
"Start broadcasting now"
|
||||
) }}
|
||||
{% endcall %}
|
||||
{% else %}
|
||||
<p class="govuk-body govuk-!-margin-bottom-3">
|
||||
Created by {{ broadcast_message.created_by.name }} and approved by
|
||||
|
||||
Reference in New Issue
Block a user