mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
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:
@@ -89,10 +89,9 @@ class BroadcastMessage(JSONModel):
|
||||
|
||||
@property
|
||||
def areas(self):
|
||||
polygons = self._dict['areas']['simple_polygons']
|
||||
library_areas = self.get_areas(self.area_ids)
|
||||
if 'ids' in self._dict['areas']:
|
||||
library_areas = self.get_areas(self.area_ids)
|
||||
|
||||
if library_areas:
|
||||
if len(library_areas) != len(self.area_ids):
|
||||
raise RuntimeError(
|
||||
f'BroadcastMessage has {len(self.area_ids)} areas '
|
||||
@@ -101,8 +100,8 @@ class BroadcastMessage(JSONModel):
|
||||
return library_areas
|
||||
|
||||
return CustomBroadcastAreas(
|
||||
area_ids=self.area_ids,
|
||||
polygons=polygons,
|
||||
names=self._dict['areas']['names'],
|
||||
polygons=self._dict['areas']['simple_polygons'],
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user