Separates "recommended time" (time_start/time_end) from actual timer duration. If duration_minutes is set, the timer counts down from that value; otherwise falls back to the time_start–time_end window. - ScheduleBlock model: add nullable duration_minutes INT column - Startup migration: idempotent ADD COLUMN for existing DBs - Schemas: duration_minutes in create, update, and out - TimerDisplay: prefer duration_minutes * 60 over time diff when set - Admin block forms: Duration (min) input on add and edit forms Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
65 lines
1.5 KiB
Python
65 lines
1.5 KiB
Python
from datetime import time
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ScheduleBlockCreate(BaseModel):
|
|
subject_id: int | None = None
|
|
time_start: time
|
|
time_end: time
|
|
duration_minutes: int | None = None
|
|
label: str | None = None
|
|
notes: str | None = None
|
|
order_index: int = 0
|
|
|
|
|
|
class ScheduleBlockUpdate(BaseModel):
|
|
subject_id: int | None = None
|
|
time_start: time | None = None
|
|
time_end: time | None = None
|
|
duration_minutes: int | None = None
|
|
label: str | None = None
|
|
notes: str | None = None
|
|
order_index: int | None = None
|
|
|
|
|
|
class ScheduleBlockOut(BaseModel):
|
|
id: int
|
|
subject_id: int | None
|
|
time_start: time
|
|
time_end: time
|
|
duration_minutes: int | None
|
|
label: str | None
|
|
notes: str | None
|
|
order_index: int
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class ScheduleTemplateCreate(BaseModel):
|
|
name: str
|
|
child_id: int | None = None
|
|
is_default: bool = False
|
|
day_start_time: time | None = None
|
|
day_end_time: time | None = None
|
|
blocks: list[ScheduleBlockCreate] = []
|
|
|
|
|
|
class ScheduleTemplateUpdate(BaseModel):
|
|
name: str | None = None
|
|
child_id: int | None = None
|
|
is_default: bool | None = None
|
|
day_start_time: time | None = None
|
|
day_end_time: time | None = None
|
|
|
|
|
|
class ScheduleTemplateOut(BaseModel):
|
|
id: int
|
|
name: str
|
|
child_id: int | None
|
|
is_default: bool
|
|
day_start_time: time | None
|
|
day_end_time: time | None
|
|
blocks: list[ScheduleBlockOut] = []
|
|
|
|
model_config = {"from_attributes": True}
|