mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 00:48:25 -04:00
DRY-up sending area updates to the API
This commit is contained in:
@@ -227,19 +227,11 @@ class BroadcastMessage(JSONModel):
|
|||||||
|
|
||||||
def add_areas(self, *new_area_ids):
|
def add_areas(self, *new_area_ids):
|
||||||
self.area_ids = list(OrderedSet(self.area_ids + list(new_area_ids)))
|
self.area_ids = list(OrderedSet(self.area_ids + list(new_area_ids)))
|
||||||
|
self._update_areas()
|
||||||
self._update(areas_2={
|
|
||||||
'ids': self.area_ids,
|
|
||||||
'simple_polygons': self.simple_polygons.as_coordinate_pairs_lat_long
|
|
||||||
})
|
|
||||||
|
|
||||||
def remove_area(self, area_id):
|
def remove_area(self, area_id):
|
||||||
self.area_ids = list(set(self._dict['areas_2']['ids']) - {area_id})
|
self.area_ids = list(set(self._dict['areas_2']['ids']) - {area_id})
|
||||||
|
self._update_areas()
|
||||||
self._update(areas_2={
|
|
||||||
'ids': self.area_ids,
|
|
||||||
'simple_polygons': self.simple_polygons.as_coordinate_pairs_lat_long
|
|
||||||
})
|
|
||||||
|
|
||||||
def _set_status_to(self, status):
|
def _set_status_to(self, status):
|
||||||
broadcast_message_api_client.update_broadcast_message_status(
|
broadcast_message_api_client.update_broadcast_message_status(
|
||||||
@@ -248,6 +240,12 @@ class BroadcastMessage(JSONModel):
|
|||||||
service_id=self.service_id,
|
service_id=self.service_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _update_areas(self):
|
||||||
|
self._update(areas_2={
|
||||||
|
'ids': self.area_ids,
|
||||||
|
'simple_polygons': self.simple_polygons.as_coordinate_pairs_lat_long
|
||||||
|
})
|
||||||
|
|
||||||
def _update(self, **kwargs):
|
def _update(self, **kwargs):
|
||||||
broadcast_message_api_client.update_broadcast_message(
|
broadcast_message_api_client.update_broadcast_message(
|
||||||
broadcast_message_id=self.id,
|
broadcast_message_id=self.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user