Files
bdinvite/backend/app/models.py
kiskaadee 8ce9a73176 refactor(auth): enforce ruff and pyright standards, add router-level auth, and enhance logged-out UI
- Apply repository standards for ruff check and ruff format across backend
- Enforce strict typing annotations (PEP 604) for pyright compliance
- Add router-level dependency protection to admin.py (dependencies=[Depends(require_admin)])
- Incorporate dedicated logged-out UI screen in AdminLayout.tsx
- Update browser SSO acceptance test to verify the logged-out state and re-login
2026-10-07 06:48:57 -05:00

111 lines
3.7 KiB
Python

from datetime import UTC, datetime
from sqlalchemy import DateTime, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from .database import Base
def utc_now() -> datetime:
return datetime.now(UTC)
class RSVP(Base):
__tablename__ = "rsvps"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(100), nullable=False)
phone: Mapped[str] = mapped_column(
String(20), nullable=False, unique=True, index=True
)
email: Mapped[str | None] = mapped_column(String(255), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, default=utc_now
)
class InvitationConfig(Base):
__tablename__ = "invitation_config"
id: Mapped[int] = mapped_column(Integer, primary_key=True, default=1)
title: Mapped[str] = mapped_column(
String(200), nullable=False, default="Birthday Party"
)
invitation_text: Mapped[str] = mapped_column(
String(500),
nullable=False,
default="You're invited to the birthday party honoring",
)
honoree_name: Mapped[str] = mapped_column(
String(200), nullable=False, default="Isabelle Snow"
)
event_date: Mapped[str] = mapped_column(
String(20), nullable=False, default="2026-10-28"
)
event_time: Mapped[str] = mapped_column(String(10), nullable=False, default="19:00")
event_timezone: Mapped[str] = mapped_column(
String(50), nullable=False, default="America/Bogota"
)
address_name: Mapped[str] = mapped_column(
String(200), nullable=False, default="Fresco Ristorante"
)
address_lines: Mapped[str] = mapped_column(
Text,
nullable=False,
default="514 S Brand Blvd\nGlendale, CA 91204",
)
map_preview_url: Mapped[str] = mapped_column(
String(500),
nullable=False,
default="https://tile.openstreetmap.org/15/8802/13443.png",
)
map_url: Mapped[str] = mapped_column(
String(500),
nullable=False,
default="https://maps.google.com/?q=Fresco+Ristorante+Glendale+CA",
)
rsvp_heading: Mapped[str] = mapped_column(
String(100), nullable=False, default="¿Nos vemos?"
)
rsvp_cta: Mapped[str] = mapped_column(
String(100), nullable=False, default="CONFIRMA TU ASISTENCIA"
)
submit_label: Mapped[str] = mapped_column(
String(100), nullable=False, default="TE VEO AHÍ"
)
msg_success: Mapped[str] = mapped_column(
String(300),
nullable=False,
default="¡Perfecto! Tu asistencia ha sido confirmada.",
)
msg_success_greeting: Mapped[str] = mapped_column(
String(100), nullable=False, default="Gracias, {name}."
)
msg_duplicate: Mapped[str] = mapped_column(
String(300),
nullable=False,
default="Parece que ya tenemos tus datos registrados.",
)
msg_error: Mapped[str] = mapped_column(
String(300),
nullable=False,
default="No pudimos registrar tu asistencia. Inténtalo nuevamente.",
)
msg_config_error: Mapped[str] = mapped_column(
String(300),
nullable=False,
default="No pudimos cargar la invitación. Inténtalo nuevamente.",
)
countdown_label: Mapped[str] = mapped_column(
String(100), nullable=False, default="NOS VEMOS EN"
)
countdown_in_progress: Mapped[str] = mapped_column(
String(100), nullable=False, default="EVENTO EN CURSO"
)
countdown_finished: Mapped[str] = mapped_column(
String(100), nullable=False, default="EVENTO FINALIZADO"
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, default=utc_now, onupdate=utc_now
)