Add optional route description field
This commit is contained in:
@@ -158,6 +158,7 @@ class PlanBody(BaseModel):
|
||||
name: str
|
||||
waypoints: list[dict]
|
||||
profile: str
|
||||
description: str | None = None
|
||||
geojson: dict | None = None
|
||||
gpxTrack: dict | None = None # full GeoJSON of reference track, if any GPX segments used
|
||||
gpxColorIdx: int | None = None
|
||||
@@ -201,6 +202,8 @@ async def create_plan(body: PlanBody, user: User = Depends(require_auth)) -> JSO
|
||||
"created_at": now,
|
||||
"updated_at": now,
|
||||
}
|
||||
if body.description:
|
||||
data["description"] = body.description
|
||||
if body.collection_id:
|
||||
data["collection_id"] = body.collection_id
|
||||
if body.dist_km is not None:
|
||||
@@ -241,6 +244,11 @@ async def update_plan(
|
||||
"profile": body.profile,
|
||||
"updated_at": int(time.time()),
|
||||
})
|
||||
# description: non-null sets, null clears
|
||||
if body.description:
|
||||
data["description"] = body.description
|
||||
else:
|
||||
data.pop("description", None)
|
||||
# collection_id: non-null assigns, null unassigns
|
||||
if body.collection_id:
|
||||
data["collection_id"] = body.collection_id
|
||||
@@ -363,6 +371,8 @@ async def create_shared(body: PlanBody, user: User = Depends(require_auth)) -> J
|
||||
"created_at": now,
|
||||
"updated_at": now,
|
||||
}
|
||||
if body.description:
|
||||
data["description"] = body.description
|
||||
if body.dist_km is not None:
|
||||
data["dist_km"] = body.dist_km
|
||||
if body.elevation_gain is not None:
|
||||
@@ -399,6 +409,10 @@ async def update_shared(
|
||||
"profile": body.profile,
|
||||
"updated_at": int(time.time()),
|
||||
})
|
||||
if body.description:
|
||||
data["description"] = body.description
|
||||
else:
|
||||
data.pop("description", None)
|
||||
if body.dist_km is not None:
|
||||
data["dist_km"] = body.dist_km
|
||||
if body.elevation_gain is not None:
|
||||
|
||||
Reference in New Issue
Block a user