mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
Currently we have: - An "areas" column in the DB that stores a JSON blob. - An "areas" field inside the "areas" JSON that stores area IDs. - Each field has to be manually copied into the JSON column. We want to move to: - An "areas" column in the DB (unchanged). - An "ids" field inside the "areas" JSON (to replace "areas"). - The Admin app sending other data inside an "areas" JSON field. The API design for areas is confusing and difficult to extend. Here we duplicate the current API functionality using an "areas_2" field. Once the Admin app is using this field, we'll be able to rename it to just "areas", which is where we want to get to. In the next commits we'll build on this to support the migration from "areas"."areas" to "areas"."ids".
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
from app.models import BroadcastStatusType
|
|
from app.schema_validation.definitions import uuid
|
|
|
|
create_broadcast_message_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST create broadcast_message schema',
|
|
'type': 'object',
|
|
'title': 'Create broadcast_message',
|
|
'properties': {
|
|
'template_id': uuid,
|
|
'service_id': uuid,
|
|
'created_by': uuid,
|
|
'personalisation': {'type': 'object'},
|
|
'starts_at': {'type': 'string', 'format': 'datetime'},
|
|
'finishes_at': {'type': 'string', 'format': 'datetime'},
|
|
'areas': {"type": "array", "items": {"type": "string"}},
|
|
'areas_2': {'type': 'object'},
|
|
'simple_polygons': {"type": "array", "items": {"type": "array"}},
|
|
'content': {'type': 'string', 'minLength': 1},
|
|
'reference': {'type': 'string', 'minLength': 1, 'maxLength': 255},
|
|
},
|
|
'required': ['service_id', 'created_by'],
|
|
'allOf': [
|
|
{'oneOf': [
|
|
{'required': ['template_id']},
|
|
{'required': ['content']},
|
|
]},
|
|
{'oneOf': [
|
|
{'required': ['template_id']},
|
|
{'required': ['reference']},
|
|
]},
|
|
],
|
|
'additionalProperties': False
|
|
}
|
|
|
|
update_broadcast_message_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST update broadcast_message schema',
|
|
'type': 'object',
|
|
'title': 'Update broadcast_message',
|
|
'properties': {
|
|
'personalisation': {'type': 'object'},
|
|
'starts_at': {'type': 'string', 'format': 'datetime'},
|
|
'finishes_at': {'type': 'string', 'format': 'datetime'},
|
|
'areas': {"type": "array", "items": {"type": "string"}},
|
|
'areas_2': {'type': 'object'},
|
|
'simple_polygons': {"type": "array", "items": {"type": "array"}},
|
|
},
|
|
'required': [],
|
|
'additionalProperties': False
|
|
}
|
|
|
|
update_broadcast_message_status_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST update broadcast_message status schema',
|
|
'type': 'object',
|
|
'title': 'Update broadcast_message',
|
|
'properties': {
|
|
'status': {'type': 'string', 'enum': BroadcastStatusType.STATUSES},
|
|
'created_by': uuid,
|
|
},
|
|
'required': ['status', 'created_by'],
|
|
'additionalProperties': False
|
|
}
|