This commit is contained in:
parent
ec9ae3afb3
commit
2050391f4d
2
dot_env
2
dot_env
@ -2,4 +2,4 @@ DATABASE='weatherapp'
|
|||||||
DB_HOST='10.1.1.1'
|
DB_HOST='10.1.1.1'
|
||||||
DB_USER='weatherapp'
|
DB_USER='weatherapp'
|
||||||
DB_PASS='YEj5zxBsM4pZlDG6NrX2'
|
DB_PASS='YEj5zxBsM4pZlDG6NrX2'
|
||||||
DB_REBUILD='True'
|
DB_REBUILD='True'
|
||||||
|
13
main.py
13
main.py
@ -135,8 +135,8 @@ async def add_location(loc: Location):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
id = int(loc.id)
|
id = int(loc.id)
|
||||||
if loc.name!= 'existing':
|
#if loc.name!= 'existing':
|
||||||
id = utils.get_available_ids(1)[0]
|
# 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)
|
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
|
None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
print(f"deleted location {id}")
|
||||||
utils.delete_location(id)
|
utils.delete_location(id)
|
||||||
|
|
||||||
|
|
||||||
@ -168,3 +169,11 @@ async def search_location(query: str):
|
|||||||
"""
|
"""
|
||||||
result = utils.search_location(query)
|
result = utils.search_location(query)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@app.post("/location/disable")
|
||||||
|
async def search_location(id: int,
|
||||||
|
user: int
|
||||||
|
):
|
||||||
|
|
||||||
|
result = utils.config_disable_location(id, user)
|
||||||
|
return result
|
||||||
|
3
utils.py
3
utils.py
@ -101,12 +101,11 @@ def config_disable_location(id, user):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
id (int): The ID of the location to be disabled.
|
id (int): The ID of the location to be disabled.
|
||||||
user (int): The user ID associated with the location configuration.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
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()
|
db_session.commit()
|
||||||
|
|
||||||
def delete_location(id):
|
def delete_location(id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user