mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Check that all areas are in the library
We should assume to start with that areas come either from the library or from the JSON, and not a combination of the two.
This commit is contained in:
@@ -78,9 +78,17 @@ class BroadcastMessage(JSONModel):
|
||||
|
||||
@property
|
||||
def areas(self):
|
||||
return self.get_areas(
|
||||
areas=self._dict['areas']
|
||||
) or CustomBroadcastAreas(
|
||||
library_areas = self.get_areas(areas=self._dict['areas'])
|
||||
|
||||
if library_areas:
|
||||
if len(library_areas) != len(self._dict['areas']):
|
||||
raise RuntimeError(
|
||||
f'BroadcastMessage has {len(self._dict["areas"])} areas '
|
||||
f'but {len(library_areas)} found in the library'
|
||||
)
|
||||
return library_areas
|
||||
|
||||
return CustomBroadcastAreas(
|
||||
areas=self._dict['areas'],
|
||||
polygons=self._dict['simple_polygons'],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user