mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Remove argument unpacking from get_areas
Making it only callable in one way is just less stuff to understand.
This commit is contained in:
@@ -227,18 +227,11 @@ class BroadcastAreaLibraries(SerialisedModelCollection, GetItemByIdMixin):
|
||||
def __init__(self):
|
||||
self.items = BroadcastAreasRepository().get_libraries()
|
||||
|
||||
def get_areas(self, *area_ids):
|
||||
# allow people to call `get_areas('a', 'b') or get_areas(['a', 'b'])`
|
||||
if len(area_ids) == 1 and isinstance(area_ids[0], list):
|
||||
area_ids = area_ids[0]
|
||||
|
||||
def get_areas(self, area_ids):
|
||||
areas = BroadcastAreasRepository().get_areas(area_ids)
|
||||
return [BroadcastArea(area) for area in areas]
|
||||
|
||||
def get_areas_with_simple_polygons(self, *area_ids):
|
||||
if len(area_ids) == 1 and isinstance(area_ids[0], list):
|
||||
area_ids = area_ids[0]
|
||||
|
||||
def get_areas_with_simple_polygons(self, area_ids):
|
||||
areas = BroadcastAreasRepository().get_areas_with_simple_polygons(area_ids)
|
||||
return [BroadcastArea.from_row_with_simple_polygons(area) for area in areas]
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ def choose_broadcast_sub_area(service_id, broadcast_message_id, library_slug, ar
|
||||
broadcast_message_id,
|
||||
service_id=current_service.id,
|
||||
)
|
||||
area = BroadcastMessage.libraries.get_areas(area_slug)[0]
|
||||
area = BroadcastMessage.libraries.get_areas([area_slug])[0]
|
||||
|
||||
back_link = _get_broadcast_sub_area_back_link(service_id, broadcast_message_id, library_slug)
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ from app.notify_client.broadcast_message_api_client import (
|
||||
broadcast_message_api_client,
|
||||
)
|
||||
|
||||
ESTIMATED_AREA_OF_LARGEST_UK_COUNTY = broadcast_area_libraries.get_areas(
|
||||
ESTIMATED_AREA_OF_LARGEST_UK_COUNTY = broadcast_area_libraries.get_areas([
|
||||
'ctyua19-E10000023' # North Yorkshire
|
||||
)[0].polygons.estimated_area
|
||||
])[0].polygons.estimated_area
|
||||
|
||||
|
||||
class BroadcastMessage(JSONModel):
|
||||
@@ -203,7 +203,7 @@ class BroadcastMessage(JSONModel):
|
||||
|
||||
def get_areas(self, areas):
|
||||
return broadcast_area_libraries.get_areas(
|
||||
*areas
|
||||
areas
|
||||
)
|
||||
|
||||
def get_simple_polygons(self, areas):
|
||||
|
||||
Reference in New Issue
Block a user