mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Support broadcasts with no areas data
Previously we used to return an empty CustomBroadcastAreas object, which doesn't make sense for broadcasts created in this app.
This commit is contained in:
@@ -99,10 +99,15 @@ class BroadcastMessage(JSONModel):
|
|||||||
)
|
)
|
||||||
return library_areas
|
return library_areas
|
||||||
|
|
||||||
return CustomBroadcastAreas(
|
polygons = self._dict['areas'].get('simple_polygons', [])
|
||||||
names=self._dict['areas']['names'],
|
|
||||||
polygons=self._dict['areas']['simple_polygons'],
|
if polygons:
|
||||||
)
|
return CustomBroadcastAreas(
|
||||||
|
names=self._dict['areas']['names'],
|
||||||
|
polygons=polygons,
|
||||||
|
)
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def area_ids(self):
|
def area_ids(self):
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ def test_content_comes_from_attribute_not_template():
|
|||||||
@pytest.mark.parametrize(('areas', 'expected_length'), [
|
@pytest.mark.parametrize(('areas', 'expected_length'), [
|
||||||
({'ids': []}, 0),
|
({'ids': []}, 0),
|
||||||
({'ids': ['wd20-E05009372']}, 1),
|
({'ids': ['wd20-E05009372']}, 1),
|
||||||
|
({'no data': 'just created'}, 0),
|
||||||
({'names': ['somewhere'], 'simple_polygons': [[[3.5, 1.5]]]}, 1)
|
({'names': ['somewhere'], 'simple_polygons': [[[3.5, 1.5]]]}, 1)
|
||||||
])
|
])
|
||||||
def test_areas(
|
def test_areas(
|
||||||
|
|||||||
Reference in New Issue
Block a user