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:
45
backend/app/models/schedule.py
Normal file
45
backend/app/models/schedule.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from datetime import time
|
||||
from sqlalchemy import String, Boolean, ForeignKey, Time, Text, Integer
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from app.models.base import Base, TimestampMixin
|
||||
|
||||
|
||||
class ScheduleTemplate(TimestampMixin, Base):
|
||||
__tablename__ = "schedule_templates"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
child_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("children.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
is_default: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
user: Mapped["User"] = relationship("User", back_populates="schedule_templates") # noqa: F821
|
||||
child: Mapped["Child | None"] = relationship("Child") # noqa: F821
|
||||
blocks: Mapped[list["ScheduleBlock"]] = relationship(
|
||||
"ScheduleBlock", back_populates="template", cascade="all, delete-orphan", order_by="ScheduleBlock.order_index"
|
||||
)
|
||||
daily_sessions: Mapped[list["DailySession"]] = relationship( # noqa: F821
|
||||
"DailySession", back_populates="template"
|
||||
)
|
||||
|
||||
|
||||
class ScheduleBlock(Base):
|
||||
__tablename__ = "schedule_blocks"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
template_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("schedule_templates.id", ondelete="CASCADE"), nullable=False
|
||||
)
|
||||
subject_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("subjects.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
time_start: Mapped[time] = mapped_column(Time, nullable=False)
|
||||
time_end: Mapped[time] = mapped_column(Time, nullable=False)
|
||||
label: Mapped[str | None] = mapped_column(String(100), nullable=True) # override subject name
|
||||
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
order_index: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
template: Mapped["ScheduleTemplate"] = relationship("ScheduleTemplate", back_populates="blocks")
|
||||
subject: Mapped["Subject | None"] = relationship("Subject", back_populates="schedule_blocks") # noqa: F821
|
||||
Reference in New Issue
Block a user