Add Morning Routine to Admin and TV greeting state
Adds a per-user Morning Routine item list that appears in the TV dashboard Activities panel during the "Good Morning" countdown (before the first block starts). - morning_routine_items table (auto-created on startup) - CRUD API at /api/morning-routine (auth-required) - Items included in the public DashboardSnapshot so TV gets them without auth - Morning Routine section in Admin page (same add/edit/delete UX as subject options) - TV Activities column shows routine items when no block is active, switches to subject options once a block starts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from sqlalchemy.orm import selectinload
|
||||
|
||||
from app.dependencies import get_db
|
||||
from app.models.child import Child
|
||||
from app.models.morning_routine import MorningRoutineItem
|
||||
from app.models.schedule import ScheduleBlock, ScheduleTemplate
|
||||
from app.models.subject import Subject # noqa: F401 — needed for selectinload chain
|
||||
from app.models.session import DailySession, TimerEvent
|
||||
@@ -97,6 +98,13 @@ async def get_dashboard(child_id: int, db: AsyncSession = Depends(get_db)):
|
||||
# Paused if the last tick event was a pause (last_start is None but events exist)
|
||||
is_paused = bool(tick_events) and tick_events[-1].event_type == "pause"
|
||||
|
||||
routine_result = await db.execute(
|
||||
select(MorningRoutineItem)
|
||||
.where(MorningRoutineItem.user_id == child.user_id)
|
||||
.order_by(MorningRoutineItem.order_index, MorningRoutineItem.id)
|
||||
)
|
||||
morning_routine = [item.text for item in routine_result.scalars().all()]
|
||||
|
||||
return DashboardSnapshot(
|
||||
session=session,
|
||||
child=child,
|
||||
@@ -106,4 +114,5 @@ async def get_dashboard(child_id: int, db: AsyncSession = Depends(get_db)):
|
||||
is_paused=is_paused,
|
||||
day_start_time=day_start_time,
|
||||
day_end_time=day_end_time,
|
||||
morning_routine=morning_routine,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user