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>
This commit is contained in:
1 parent
848cff35b3
commit
ff2860f7be
13 files changed
+711
-9
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from app.models.base import Base, UTCDateTime, utcnow
|
||||
from app.models.clip import Clip, ClipKind
|
||||
from app.models.login_attempt import LoginAttempt
|
||||
from app.models.project import PROJECT_COLORS, Project
|
||||
from app.models.session import UserSession
|
||||
from app.models.user import Role, User
|
||||
|
||||
@@ -9,6 +10,8 @@ __all__ = [
|
||||
"Clip",
|
||||
"ClipKind",
|
||||
"LoginAttempt",
|
||||
"PROJECT_COLORS",
|
||||
"Project",
|
||||
"Role",
|
||||
"UTCDateTime",
|
||||
"User",
|
||||
|
||||
@@ -16,10 +16,16 @@ class ClipKind(enum.StrEnum):
|
||||
|
||||
class Clip(Base):
|
||||
__tablename__ = "clips"
|
||||
__table_args__ = (Index("ix_clips_user_order", "user_id", "pinned", "updated_at"),)
|
||||
__table_args__ = (
|
||||
Index("ix_clips_user_order", "user_id", "pinned", "updated_at"),
|
||||
Index("ix_clips_user_project", "user_id", "project_id"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"))
|
||||
project_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("projects.id", ondelete="SET NULL", name="fk_clips_project_id")
|
||||
)
|
||||
kind: Mapped[ClipKind] = mapped_column(
|
||||
Enum(ClipKind, native_enum=False, length=16, values_callable=lambda e: [m.value for m in e])
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
Reference in new issue
Block a user