diff --git a/dot_env b/dot_env index 2fdbce7..0d7b5ac 100644 --- a/dot_env +++ b/dot_env @@ -2,4 +2,4 @@ DATABASE='weatherapp' DB_HOST='10.1.1.1' DB_USER='weatherapp' DB_PASS='YEj5zxBsM4pZlDG6NrX2' -DB_REBUILD='True' \ No newline at end of file +DB_REBUILD='True' diff --git a/main.py b/main.py index 078a5a3..a945642 100644 --- a/main.py +++ b/main.py @@ -135,8 +135,8 @@ async def add_location(loc: Location): ) else: id = int(loc.id) - if loc.name!= 'existing': - id = utils.get_available_ids(1)[0] + #if loc.name!= 'existing': + # id = utils.get_available_ids(1)[0] utils.add_location({"id":id ,"name":loc.name,"country":loc.country,"longitude":loc.longitude,"latitude":loc.latitude, "user": loc.user}, no_commit=False) @@ -151,6 +151,7 @@ async def delete_location(id: int): None """ + print(f"deleted location {id}") utils.delete_location(id) @@ -168,3 +169,11 @@ async def search_location(query: str): """ result = utils.search_location(query) return result + +@app.post("/location/disable") +async def search_location(id: int, + user: int +): + + result = utils.config_disable_location(id, user) + return result diff --git a/utils.py b/utils.py index 0bc3267..5374494 100644 --- a/utils.py +++ b/utils.py @@ -101,12 +101,11 @@ def config_disable_location(id, user): Parameters: id (int): The ID of the location to be disabled. - user (int): The user ID associated with the location configuration. Returns: None """ - db_session.add(Config(user_id=user,location_id=id)) + db_session.query(Config).filter(Config.location_id == id and Config.user_id == user).delete() db_session.commit() def delete_location(id):