ensure you can get broadcast_areas from a list as well as from *args

This commit is contained in:
Leo Hemsted
2020-07-09 19:10:51 +01:00
committed by Toby Lorne
parent 078f1dd8d3
commit b3ed21252d
2 changed files with 18 additions and 0 deletions

View File

@@ -147,6 +147,10 @@ class BroadcastAreaLibraries(SerialisedModelCollection, GetItemByIdMixin):
yield area
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]
return list(itertools.chain(*(
[area for area in self.all_areas if area.id == area_id]
for area_id in area_ids