This commit is contained in:
parent
ec9ae3afb3
commit
2050391f4d
13
main.py
13
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
|
||||
|
3
utils.py
3
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user