Projekte pro Benutzer mit Name und Farbe, Clips optional einem Projekt zugeordnet. Löschen eines Projekts verschiebt seine Clips nach "ohne Projekt". Clip-Liste filtert nach Projekt und sucht Teiltexte in Titel und Inhalt, unabhängig von Groß-/Kleinschreibung (auch Umlaute). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import ForeignKey, String, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.models.base import Base, UTCDateTime, utcnow
|
|
|
|
# Fixed palette; the frontend maps these keys to colors that fit the dark theme
|
|
PROJECT_COLORS = ("blue", "teal", "green", "amber", "orange", "red", "pink", "violet")
|
|
|
|
|
|
class Project(Base):
|
|
__tablename__ = "projects"
|
|
__table_args__ = (UniqueConstraint("user_id", "name_key", name="uq_projects_user_name"),)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"))
|
|
name: Mapped[str] = mapped_column(String(100))
|
|
# Case-folded name, so "Work" and "work" count as the same project
|
|
name_key: Mapped[str] = mapped_column(String(100))
|
|
color: Mapped[str] = mapped_column(String(16), default="blue")
|
|
created_at: Mapped[datetime] = mapped_column(UTCDateTime, default=utcnow)
|
|
updated_at: Mapped[datetime] = mapped_column(UTCDateTime, default=utcnow)
|