Files
dbildhauerandClaude Opus 5.5 ff2860f7be feat: projekte und suche im backend
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>
2026-10-25 13:15:05 +01:00

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)