Add display_name support for users in backend and frontend
This commit introduces the `display_name` field to the user model. It updates database migrations, API endpoints, and the admin panel to handle this field. Additionally, the `display_name` is now shown in the TopBar and WinnerBadge components, improving user experience.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# backend/app/models.py
|
||||
import enum
|
||||
import uuid
|
||||
from sqlalchemy import (
|
||||
@@ -34,25 +35,24 @@ class User(Base):
|
||||
disabled: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
created_at: Mapped[str] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# NEW: Theme im Userprofil (damit es auf anderen Geräten mitkommt)
|
||||
theme_key: Mapped[str] = mapped_column(String, default="default")
|
||||
|
||||
# NEW: schöner Name für UI (TopBar / WinnerBadge)
|
||||
display_name: Mapped[str] = mapped_column(String, default="")
|
||||
|
||||
|
||||
class Game(Base):
|
||||
__tablename__ = "games"
|
||||
id: Mapped[str] = mapped_column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
|
||||
# NEW: Host (nur Host darf Winner setzen)
|
||||
host_user_id: Mapped[str] = mapped_column(String, ForeignKey("users.id"), index=True)
|
||||
|
||||
name: Mapped[str] = mapped_column(String)
|
||||
seed: Mapped[int] = mapped_column(Integer)
|
||||
created_at: Mapped[str] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# NEW: Join-Code (Kahoot-Style)
|
||||
code: Mapped[str] = mapped_column(String, unique=True, index=True)
|
||||
|
||||
# NEW: Winner (aus Users, nicht Freitext)
|
||||
winner_user_id: Mapped[str | None] = mapped_column(String, ForeignKey("users.id"), nullable=True)
|
||||
|
||||
|
||||
@@ -75,18 +75,15 @@ class Entry(Base):
|
||||
|
||||
class SheetState(Base):
|
||||
__tablename__ = "sheet_state"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("game_id", "owner_user_id", "entry_id", name="uq_sheet"),
|
||||
)
|
||||
__table_args__ = (UniqueConstraint("game_id", "owner_user_id", "entry_id", name="uq_sheet"),)
|
||||
|
||||
id: Mapped[str] = mapped_column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
game_id: Mapped[str] = mapped_column(String, ForeignKey("games.id"), index=True)
|
||||
owner_user_id: Mapped[str] = mapped_column(String, ForeignKey("users.id"), index=True)
|
||||
entry_id: Mapped[str] = mapped_column(String, ForeignKey("entries.id"), index=True)
|
||||
|
||||
status: Mapped[int] = mapped_column(SmallInteger, default=0) # 0 unknown, 1 crossed, 2 confirmed, 3 maybe
|
||||
note_tag: Mapped[str | None] = mapped_column(String, nullable=True) # null | 'i' | 'm' | 's'
|
||||
status: Mapped[int] = mapped_column(SmallInteger, default=0)
|
||||
note_tag: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
|
||||
# NEW: Chip persistieren (statt LocalStorage)
|
||||
chip: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user