- New /plan page shows all phases in order with current phase highlighted - Add GET/POST/PUT /api/agent/phases endpoints for the AI coach - Plan link added to navigation bar - Agent config updated with phase management instructions
27 lines
850 B
Python
27 lines
850 B
Python
from fastapi import APIRouter, Request, Depends
|
|
from fastapi.responses import HTMLResponse
|
|
from fastapi.templating import Jinja2Templates
|
|
from sqlalchemy import select, desc
|
|
|
|
from app.models.base import async_session
|
|
from app.models.user import User
|
|
from app.models.workout import Phase
|
|
from app.auth import get_current_user
|
|
|
|
router = APIRouter()
|
|
templates = Jinja2Templates(directory="app/templates")
|
|
|
|
|
|
@router.get("/plan", response_class=HTMLResponse)
|
|
async def plan_page(request: Request, user: User = Depends(get_current_user)):
|
|
async with async_session() as session:
|
|
result = await session.execute(
|
|
select(Phase).order_by(Phase.start_date.nulls_last())
|
|
)
|
|
phases = result.scalars().all()
|
|
|
|
return templates.TemplateResponse(request, "plan.html", {
|
|
"user": user,
|
|
"phases": phases,
|
|
})
|