Refactor shuttle and route management: price separation, premium preview design, and simplified route creation form
This commit is contained in:
@ -18,11 +18,14 @@ async def get_shuttles(
|
||||
destination: Optional[str] = Query(None),
|
||||
company_name: Optional[str] = Query(None),
|
||||
trip_type: Optional[str] = Query(None),
|
||||
is_active: bool = Query(True),
|
||||
is_active: Optional[bool] = Query(None),
|
||||
session: Session = Depends(get_session)
|
||||
):
|
||||
"""Get all shuttles with optional filters."""
|
||||
statement = select(Shuttle).where(Shuttle.is_active == is_active)
|
||||
statement = select(Shuttle)
|
||||
|
||||
if is_active is not None:
|
||||
statement = statement.where(Shuttle.is_active == is_active)
|
||||
|
||||
if origin:
|
||||
statement = statement.where(Shuttle.origin.contains(origin))
|
||||
@ -159,3 +162,21 @@ async def delete_shuttle(
|
||||
session.delete(db_shuttle)
|
||||
session.commit()
|
||||
return {"ok": True}
|
||||
|
||||
@router.patch("/{shuttle_id}/status")
|
||||
async def update_shuttle_status(
|
||||
shuttle_id: UUID,
|
||||
is_active: bool = Query(...),
|
||||
session: Session = Depends(get_session),
|
||||
_: bool = Depends(get_current_admin)
|
||||
):
|
||||
"""Update shuttle active status (Admin only)."""
|
||||
db_shuttle = session.get(Shuttle, shuttle_id)
|
||||
if not db_shuttle:
|
||||
raise HTTPException(status_code=404, detail="Shuttle not found")
|
||||
|
||||
db_shuttle.is_active = is_active
|
||||
session.add(db_shuttle)
|
||||
session.commit()
|
||||
session.refresh(db_shuttle)
|
||||
return db_shuttle
|
||||
|
||||
Reference in New Issue
Block a user