groupe-meditation/backend/app/models/affectation.py
2026-03-04 14:01:00 -05:00

23 lines
1.1 KiB
Python

"""Table affectations."""
import uuid
from datetime import date, datetime, timezone
from sqlalchemy import String, Date, Text, ForeignKey, Enum as SAEnum
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
class Affectation(Base):
__tablename__ = "affectations"
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] = mapped_column(ForeignKey("membres.id"), nullable=False)
poste_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("postes.id"), nullable=False)
date_debut: Mapped[date] = mapped_column(Date, nullable=False)
date_fin: Mapped[date | None] = mapped_column(Date)
statut: Mapped[str] = mapped_column(SAEnum("actif", "termine", name="statut_affectation"), default="actif")
note_transition: Mapped[str | None] = mapped_column(Text)
termine_par: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("membres.id"))
membre = relationship("Membre", back_populates="affectations", foreign_keys=[membre_id])
poste = relationship("Poste")