mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-03 00:50:29 -04:00
Make alert page work for rejected broadcasts
The code for this page was making assumptions about properties which aren’t present on rejected broadcasts. This commit accounts for those properties and presents the relevant elements on the page.
This commit is contained in:
@@ -158,7 +158,7 @@ class BroadcastMessage(JSONModel):
|
||||
|
||||
@cached_property
|
||||
def approved_by(self):
|
||||
return User.from_id(self.approved_by_id)
|
||||
return User.from_id(self.approved_by_id) if self.approved_by_id else None
|
||||
|
||||
@cached_property
|
||||
def cancelled_by(self):
|
||||
|
||||
@@ -116,6 +116,11 @@
|
||||
<a href="{{ url_for('.cancel_broadcast_message', service_id=current_service.id, broadcast_message_id=broadcast_message.id) }}" class="destructive-link destructive-link--no-visited-state">Stop broadcasting</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% elif broadcast_message.status == 'rejected' %}
|
||||
<p class="govuk-body govuk-!-margin-bottom-4">
|
||||
Rejected
|
||||
{{ broadcast_message.updated_at|format_datetime_human }}.
|
||||
</p>
|
||||
{% else %}
|
||||
<p class="govuk-body govuk-!-margin-bottom-4">
|
||||
Broadcast
|
||||
@@ -150,10 +155,13 @@
|
||||
<p class="govuk-body govuk-!-margin-bottom-3">
|
||||
{% if broadcast_message.created_by %}
|
||||
Prepared by {{ broadcast_message.created_by.name }}
|
||||
{% else %}
|
||||
{%- else %}
|
||||
Created from an API call
|
||||
{% endif %}
|
||||
and approved by {{ broadcast_message.approved_by.name }}.
|
||||
{%- endif %}
|
||||
{%- if broadcast_message.approved_by %}
|
||||
and approved by {{ broadcast_message.approved_by.name }}
|
||||
{%- endif %}
|
||||
{{- '.' }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1404,6 +1404,13 @@ def test_start_broadcasting(
|
||||
'Prepared by Alice and approved by Bob.',
|
||||
'Stopped by Carol yesterday at 9:21pm.',
|
||||
]),
|
||||
('.view_rejected_broadcast', False, {
|
||||
'status': 'rejected',
|
||||
'updated_at': '2020-02-21T21:21:21.000000',
|
||||
}, [
|
||||
'Rejected yesterday at 9:21pm.',
|
||||
'Prepared by Alice and approved by Bob.',
|
||||
]),
|
||||
))
|
||||
@freeze_time('2020-02-22T22:22:22.000000')
|
||||
def test_view_broadcast_message_page(
|
||||
@@ -1505,6 +1512,7 @@ def test_view_broadcast_message_shows_correct_highlighted_navigation(
|
||||
starts_at='2020-02-20T20:20:20.000000',
|
||||
finishes_at='2021-12-21T21:21:21.000000',
|
||||
cancelled_at='2021-01-01T01:01:01.000000',
|
||||
updated_at='2021-01-01T01:01:01.000000',
|
||||
status=status,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user