mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
add broadcast message crud
new blueprint `/service/<id>/broadcast-message` with the following endpoints: * GET / - get all broadcast messages for a service * GET /<id> - get a single broadcast message * POST / - create a new broadcast message * POST /<id> - update an existing broadcast message's data * POST /<id>/status - move a broadcast message to a new status I've kept the regular data update (eg personalisation, start and end times) separate from the status update, just to keep separation of concerns a bit more rigid, especially around who can update. I've included schemas for the three POSTs, they're pretty straightforward.
This commit is contained in:
26
app/dao/broadcast_message_dao.py
Normal file
26
app/dao/broadcast_message_dao.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from app import db
|
||||
from app.models import BroadcastMessage
|
||||
from app.dao.dao_utils import transactional
|
||||
|
||||
|
||||
@transactional
|
||||
def dao_create_broadcast_message(broadcast_message):
|
||||
db.session.add(broadcast_message)
|
||||
|
||||
|
||||
@transactional
|
||||
def dao_update_broadcast_message(broadcast_message):
|
||||
db.session.add(broadcast_message)
|
||||
|
||||
|
||||
def dao_get_broadcast_message_by_id_and_service_id(broadcast_message_id, service_id):
|
||||
return BroadcastMessage.query.filter(
|
||||
BroadcastMessage.id == broadcast_message_id,
|
||||
BroadcastMessage.service_id == service_id
|
||||
).one()
|
||||
|
||||
|
||||
def dao_get_broadcast_messages_for_service(service_id):
|
||||
return BroadcastMessage.query.filter(
|
||||
BroadcastMessage.service_id == service_id
|
||||
).order_by(BroadcastMessage.created_at)
|
||||
Reference in New Issue
Block a user