Support custom broadcasts (without area IDs)

Custom broadcasts created directly via the API app won't have area
IDs since [1], where we started to distinguish between "names" (all
broadcasts have these) and IDs (for broadcasts created in this app).
We forgot to propagate the distinction into the code here.

This code fixes the bug for all broadcasts created after [1]. Any
custom broadcasts created before [1] will have their "ids" field set
instead of "names" so we won't show anything for them. This seems
reasonable as we don't support custom broadcasts yet.

[1]: 023a06d5fb
This commit is contained in:
Ben Thorner
2021-09-06 10:02:01 +01:00
parent 47132d28d6
commit 411fda81c0
6 changed files with 32 additions and 12 deletions

View File

@@ -678,6 +678,7 @@ def broadcast_message_json(
updated_at=None,
approved_by_id=None,
cancelled_by_id=None,
areas=None,
area_ids=None,
simple_polygons=None,
content=None,
@@ -696,7 +697,7 @@ def broadcast_message_json(
'reference': reference,
'personalisation': {},
'areas': {
'areas': areas or {
'ids': area_ids or ['ctry19-E92000001', 'ctry19-S92000003'],
'simple_polygons': simple_polygons or [],
},