add get_earlier_provider_message fn to broadcast_event

replacing get_earlier_provider_messages. The old function returned the
previous references for earlier events for a broadcast_message. However,
these depend on the message sent to a specific provider, so the function
needs to change. It now takes in a provider, and only returns
broadcast_provider_messages sent to that provider. If there are earlier
broadcast_events without a provider_message for the chosen provider, it
raises an exception - you cannot cancel a message if all the previous
events have not been created properly (as we wouldn't know what
references to cancel).
This commit is contained in:
Leo Hemsted
2020-11-17 12:35:10 +00:00
parent f12c949ae9
commit 0257774cfa
6 changed files with 72 additions and 24 deletions

View File

@@ -54,7 +54,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
headline="GOV.UK Notify Broadcast",
description=broadcast_event.transmitted_content['body'],
areas=areas,
references=broadcast_event.get_earlier_message_references(),
previous_provider_messages=broadcast_event.get_earlier_provider_messages(provider),
sent=broadcast_event.sent_at_as_cap_datetime_string,
expires=broadcast_event.transmitted_finishes_at_as_cap_datetime_string,
)
@@ -64,7 +64,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
headline="GOV.UK Notify Broadcast",
description=broadcast_event.transmitted_content['body'],
areas=areas,
references=broadcast_event.get_earlier_message_references(),
previous_provider_messages=broadcast_event.get_earlier_provider_messages(provider),
sent=broadcast_event.sent_at_as_cap_datetime_string,
expires=broadcast_event.transmitted_finishes_at_as_cap_datetime_string,
)