allow overlap (note) tags
This commit is contained in:
@@ -147,6 +147,7 @@ class TripCreate(BaseModel):
|
||||
start_date: str # YYYY-MM-DD
|
||||
end_date: str # YYYY-MM-DD
|
||||
available_tags: List[str] = [] # tag labels configured for this trip
|
||||
overlap_tags: List[str] = [] # subset of available_tags that allow time overlap
|
||||
|
||||
|
||||
class TripEventCreate(BaseModel):
|
||||
|
||||
@@ -208,6 +208,7 @@ async def create_trip(body: TripCreate):
|
||||
"end_date": body.end_date,
|
||||
"attendees": {}, # {discord_user_id: discord_username}
|
||||
"available_tags": body.available_tags,
|
||||
"overlap_tags": body.overlap_tags,
|
||||
"created_at": now,
|
||||
}
|
||||
await fstore.doc_set("trips", trip_id, doc, merge=False)
|
||||
@@ -226,13 +227,14 @@ async def get_trip(trip_id: str):
|
||||
|
||||
@router.put("/{trip_id}/tags")
|
||||
async def update_trip_tags(trip_id: str, body: dict):
|
||||
"""Replace the trip's available tag list."""
|
||||
"""Replace the trip's available tag list and overlap-allowed tag list."""
|
||||
trip = await fstore.doc_get("trips", trip_id)
|
||||
if not trip:
|
||||
raise HTTPException(404, f"Trip '{trip_id}' not found.")
|
||||
tags = [str(t) for t in body.get("available_tags", []) if t]
|
||||
await fstore.doc_update("trips", trip_id, {"available_tags": tags})
|
||||
return {"available_tags": tags}
|
||||
overlap = [str(t) for t in body.get("overlap_tags", []) if t and t in tags]
|
||||
await fstore.doc_update("trips", trip_id, {"available_tags": tags, "overlap_tags": overlap})
|
||||
return {"available_tags": tags, "overlap_tags": overlap}
|
||||
|
||||
|
||||
@router.delete("/{trip_id}")
|
||||
|
||||
Reference in New Issue
Block a user