forbid editing after broadcast message goes live

only allow editing while in:

* draft
* pending-approval
* rejected (not too sure if/how this'll be used, so easier to include it
 for now)
This commit is contained in:
Leo Hemsted
2020-07-10 15:30:25 +01:00
parent bc0cfed468
commit 8dda1a5123
4 changed files with 39 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
from datetime import datetime
import iso8601
from flask import Blueprint, jsonify, request, current_app
from flask import Blueprint, jsonify, request, current_app, abort
from app.config import QueueNames
from app.dao.templates_dao import dao_get_template_by_id_and_service_id
@@ -85,6 +85,12 @@ def update_broadcast_message(service_id, broadcast_message_id):
broadcast_message = dao_get_broadcast_message_by_id_and_service_id(broadcast_message_id, service_id)
if broadcast_message.status not in BroadcastStatusType.PRE_BROADCAST_STATUSES:
abort(
400,
f'Cannot update broadcast_message {broadcast_message.id} while it has status {broadcast_message.status}'
)
if 'personalisation' in data:
broadcast_message.personalisation = data['personalisation']
if 'starts_at' in data: