- Auto-create a locked "Meeting" subject for every user on registration and seed it for all existing users on startup - Meeting subject cannot be deleted or renamed (is_system flag) - 5-minute corner toast warning on Dashboard and TV with live countdown, dismiss button, and 1-minute re-notify if dismissed - At start time: full-screen TV overlay with 30-second auto-dismiss, automatic pause of running block, switch to Meeting block, and auto-start of Meeting timer - Web Audio API chimes: rising on warnings, falling at meeting start - Update README with Meeting subject and notification system docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
from sqlalchemy import String, Boolean, ForeignKey, Text, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class Subject(TimestampMixin, Base):
|
|
__tablename__ = "subjects"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
|
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
color: Mapped[str] = mapped_column(String(7), default="#10B981") # hex color
|
|
icon: Mapped[str] = mapped_column(String(10), default="📚") # emoji
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
|
is_system: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
|
|
user: Mapped["User"] = relationship("User", back_populates="subjects") # noqa: F821
|
|
schedule_blocks: Mapped[list["ScheduleBlock"]] = relationship( # noqa: F821
|
|
"ScheduleBlock", back_populates="subject"
|
|
)
|
|
activity_logs: Mapped[list["ActivityLog"]] = relationship( # noqa: F821
|
|
"ActivityLog", back_populates="subject"
|
|
)
|
|
options: Mapped[list["SubjectOption"]] = relationship(
|
|
"SubjectOption", back_populates="subject", cascade="all, delete-orphan",
|
|
order_by="SubjectOption.order_index"
|
|
)
|
|
|
|
|
|
class SubjectOption(Base):
|
|
__tablename__ = "subject_options"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
subject_id: Mapped[int] = mapped_column(
|
|
ForeignKey("subjects.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
text: Mapped[str] = mapped_column(Text, nullable=False)
|
|
order_index: Mapped[int] = mapped_column(Integer, default=0)
|
|
|
|
subject: Mapped["Subject"] = relationship("Subject", back_populates="options")
|