✨ Place GPX, 🐛 pop fix
This commit is contained in:
parent
cdbb67caae
commit
b0cbd0efb5
@ -1 +1 @@
|
||||
__version__ = "1.1.3"
|
||||
__version__ = "1.2.0"
|
||||
|
||||
@ -172,7 +172,6 @@ class PlaceUpdate(PlaceBase):
|
||||
place: str | None = None
|
||||
category_id: int | None = None
|
||||
image: str | None = None
|
||||
gpx: str | None = None
|
||||
|
||||
|
||||
class PlaceRead(PlaceBase):
|
||||
|
||||
@ -31,6 +31,7 @@ def create_place(
|
||||
lat=place.lat,
|
||||
lng=place.lng,
|
||||
place=place.place,
|
||||
gpx=place.gpx,
|
||||
allowdog=place.allowdog,
|
||||
description=place.description,
|
||||
price=place.price,
|
||||
@ -79,6 +80,7 @@ async def create_places(
|
||||
lat=place.lat,
|
||||
lng=place.lng,
|
||||
place=place.place,
|
||||
gpx=place.gpx,
|
||||
allowdog=place.allowdog,
|
||||
description=place.description,
|
||||
price=place.price,
|
||||
@ -114,7 +116,7 @@ def update_place(
|
||||
verify_exists_and_owns(current_user, db_place)
|
||||
|
||||
place_data = place.model_dump(exclude_unset=True)
|
||||
image = place_data.pop("image")
|
||||
image = place_data.pop("image", None)
|
||||
if image:
|
||||
try:
|
||||
image_bytes = b64img_decode(image)
|
||||
@ -130,7 +132,6 @@ def update_place(
|
||||
session.commit()
|
||||
session.refresh(image)
|
||||
|
||||
place_data.pop("image")
|
||||
place_data["image_id"] = image.id
|
||||
|
||||
if db_place.image_id:
|
||||
@ -170,3 +171,15 @@ def delete_place(
|
||||
session.delete(db_place)
|
||||
session.commit()
|
||||
return {}
|
||||
|
||||
|
||||
@router.get("/{place_id}", response_model=PlaceRead)
|
||||
def get_place(
|
||||
session: SessionDep,
|
||||
place_id: int,
|
||||
current_user: Annotated[str, Depends(get_current_username)],
|
||||
) -> PlaceRead:
|
||||
db_place = session.get(Place, place_id)
|
||||
verify_exists_and_owns(current_user, db_place)
|
||||
|
||||
return PlaceRead.serialize(db_place, exclude_gpx=False)
|
||||
|
||||
@ -32,7 +32,9 @@ def put_user_settings(
|
||||
|
||||
user_data = data.model_dump(exclude_unset=True)
|
||||
if "do_not_display" in user_data:
|
||||
user_data["do_not_display"] = ",".join(user_data["do_not_display"]) if user_data["do_not_display"] else ""
|
||||
user_data["do_not_display"] = (
|
||||
",".join(user_data["do_not_display"]) if user_data["do_not_display"] else ""
|
||||
)
|
||||
|
||||
for key, value in user_data.items():
|
||||
setattr(db_user, key, value)
|
||||
|
||||
@ -107,10 +107,9 @@ def update_trip(
|
||||
|
||||
db_trip.image_id = image.id
|
||||
|
||||
if "place_ids" in trip_data: # Could be empty [], so 'in'
|
||||
place_ids = trip_data.pop("place_ids")
|
||||
place_ids = trip_data.pop("place_ids", None)
|
||||
if place_ids is not None: # Could be empty [], so 'in'
|
||||
db_trip.places.clear()
|
||||
if place_ids:
|
||||
for place_id in place_ids:
|
||||
db_place = session.get(Place, place_id)
|
||||
verify_exists_and_owns(current_user, db_place)
|
||||
@ -300,8 +299,8 @@ def update_tripitem(
|
||||
raise HTTPException(status_code=400, detail="Bad request")
|
||||
|
||||
item_data = item.model_dump(exclude_unset=True)
|
||||
if item_data.get("place"):
|
||||
place_id = item_data.pop("place")
|
||||
place_id = item_data.pop("place", None)
|
||||
if place_id:
|
||||
db_item.place_id = place_id
|
||||
|
||||
for key, value in item_data.items():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user