From 31a9b92e611d2a1aa6db2ea51b9a02a048ae9861 Mon Sep 17 00:00:00 2001 From: Pablo Grill Date: Tue, 22 Dec 2020 13:51:49 -0300 Subject: [PATCH] Fix in area endpoints. (#108) --- api/routers/areas.py | 4 ++-- api/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/routers/areas.py b/api/routers/areas.py index a10a6e12..3d102647 100644 --- a/api/routers/areas.py +++ b/api/routers/areas.py @@ -44,7 +44,7 @@ async def create_area(new_area: AreaConfigDTO, reboot_processor: Optional[bool] Adds a new area to the processor. """ config_dict = extract_config() - areas_name = [x for x in config_dict.keys() if x.startswith("Area")] + areas_name = [x for x in config_dict.keys() if x.startswith("Area_")] areas = [map_section_from_config(x, config_dict) for x in areas_name] if new_area.id in [area["id"] for area in areas]: raise HTTPException(status_code=400, detail="Area already exists") @@ -97,7 +97,7 @@ async def delete_area(area_id: str, reboot_processor: Optional[bool] = True): Deletes the configuration related to the area """ config_dict = extract_config() - areas_name = [x for x in config_dict.keys() if x.startswith("Area")] + areas_name = [x for x in config_dict.keys() if x.startswith("Area_")] areas = [map_section_from_config(x, config_dict) for x in areas_name] areas_ids = [area["id"] for area in areas] try: diff --git a/api/utils.py b/api/utils.py index 162bb799..b6c189fd 100644 --- a/api/utils.py +++ b/api/utils.py @@ -80,7 +80,7 @@ def handle_response(response, success, status_code=status.HTTP_200_OK): def reestructure_areas(config_dict): """Ensure that all [Area_0, Area_1, ...] are consecutive""" - area_names = [x for x in config_dict.keys() if x.startswith("Area")] + area_names = [x for x in config_dict.keys() if x.startswith("Area_")] area_names.sort() for index, area_name in enumerate(area_names): if f"Area_{index}" != area_name: