Validate that both polygons and areas have to be updated

Because areas and polygons for broadcast messages should
be in sync.
This commit is contained in:
Pea Tyczynska
2020-09-07 15:10:04 +01:00
parent 5927aae019
commit b3ff172780
2 changed files with 33 additions and 1 deletions

View File

@@ -132,6 +132,12 @@ def update_broadcast_message(service_id, broadcast_message_id):
status_code=400
)
if ('areas' in data and 'simple_polygons' not in data) or ('areas' not in data and 'simple_polygons' in data):
raise InvalidRequest(
f'Cannot update broadcast_message {broadcast_message.id}, areas or polygons are missing.',
status_code=400
)
if 'personalisation' in data:
broadcast_message.personalisation = data['personalisation']
if 'starts_at' in data: