26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
"""Table jetons — Remise de jetons de sobriété."""
|
|
import uuid
|
|
from datetime import date, datetime, timezone
|
|
from sqlalchemy import String, Integer, Date, DateTime, ForeignKey, Enum as SAEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from app.core.database import Base
|
|
|
|
|
|
class Jeton(Base):
|
|
__tablename__ = "jetons"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
|
groupe_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("groupes.id"), nullable=False)
|
|
membre_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("membres.id"))
|
|
type_jeton: Mapped[str] = mapped_column(
|
|
SAEnum(
|
|
"desir", "24h", "1mois", "2mois", "3mois",
|
|
"6mois", "9mois", "1an", "multiple",
|
|
name="type_jeton",
|
|
),
|
|
nullable=False,
|
|
)
|
|
date_remise: Mapped[date] = mapped_column(Date, nullable=False)
|
|
annees: Mapped[int | None] = mapped_column(Integer) # pour type_jeton='multiple'
|
|
remis_par: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("membres.id"))
|
|
cree_le: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
|