mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Ensure broadcast with no areas cannot be approved
This is already checked by admin app, but we want to have a fallback safety measure as a precaution.
This commit is contained in:
@@ -59,6 +59,11 @@ def _update_broadcast_message(broadcast_message, new_status, updating_user):
|
||||
f'User {updating_user.id} cannot approve their own broadcast_message {broadcast_message.id}',
|
||||
status_code=400
|
||||
)
|
||||
elif not broadcast_message.areas:
|
||||
raise InvalidRequest(
|
||||
f'broadcast_message {broadcast_message.id} has no selected areas and so cannot be broadcasted.',
|
||||
status_code=400
|
||||
)
|
||||
else:
|
||||
broadcast_message.approved_at = datetime.utcnow()
|
||||
broadcast_message.approved_by = updating_user
|
||||
|
||||
Reference in New Issue
Block a user