Initial project scaffold
Full-stack homeschool web app with FastAPI backend, Vue 3 frontend, MySQL database, and Docker Compose orchestration. Includes JWT auth, WebSocket real-time TV dashboard, schedule builder, activity logging, and multi-child support. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
55
backend/app/models/session.py
Normal file
55
backend/app/models/session.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from datetime import date, datetime
|
||||
from sqlalchemy import Date, DateTime, ForeignKey, String, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from app.models.base import Base, TimestampMixin
|
||||
import enum
|
||||
|
||||
|
||||
class TimerEventType(str, enum.Enum):
|
||||
start = "start"
|
||||
pause = "pause"
|
||||
resume = "resume"
|
||||
complete = "complete"
|
||||
skip = "skip"
|
||||
|
||||
|
||||
class DailySession(TimestampMixin, Base):
|
||||
__tablename__ = "daily_sessions"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
child_id: Mapped[int] = mapped_column(ForeignKey("children.id", ondelete="CASCADE"), nullable=False)
|
||||
template_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("schedule_templates.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
session_date: Mapped[date] = mapped_column(Date, nullable=False)
|
||||
is_active: Mapped[bool] = mapped_column(default=True)
|
||||
current_block_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("schedule_blocks.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
|
||||
child: Mapped["Child"] = relationship("Child", back_populates="daily_sessions") # noqa: F821
|
||||
template: Mapped["ScheduleTemplate | None"] = relationship( # noqa: F821
|
||||
"ScheduleTemplate", back_populates="daily_sessions"
|
||||
)
|
||||
current_block: Mapped["ScheduleBlock | None"] = relationship("ScheduleBlock", foreign_keys=[current_block_id]) # noqa: F821
|
||||
timer_events: Mapped[list["TimerEvent"]] = relationship(
|
||||
"TimerEvent", back_populates="session", cascade="all, delete-orphan"
|
||||
)
|
||||
activity_logs: Mapped[list["ActivityLog"]] = relationship( # noqa: F821
|
||||
"ActivityLog", back_populates="session"
|
||||
)
|
||||
|
||||
|
||||
class TimerEvent(Base):
|
||||
__tablename__ = "timer_events"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
session_id: Mapped[int] = mapped_column(ForeignKey("daily_sessions.id", ondelete="CASCADE"), nullable=False)
|
||||
block_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("schedule_blocks.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
event_type: Mapped[str] = mapped_column(String(20), nullable=False)
|
||||
occurred_at: Mapped[datetime] = mapped_column(DateTime, default=func.now(), server_default=func.now())
|
||||
|
||||
session: Mapped["DailySession"] = relationship("DailySession", back_populates="timer_events")
|
||||
block: Mapped["ScheduleBlock | None"] = relationship("ScheduleBlock") # noqa: F821
|
||||
Reference in New Issue
Block a user