31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
|
|
"""Table taches — tâches assignables aux postes."""
|
||
|
|
import uuid
|
||
|
|
from datetime import datetime, timezone
|
||
|
|
from sqlalchemy import String, Text, DateTime, ForeignKey, Integer
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
from app.core.database import Base
|
||
|
|
|
||
|
|
|
||
|
|
class Tache(Base):
|
||
|
|
__tablename__ = "taches"
|
||
|
|
|
||
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
||
|
|
nom: Mapped[str] = mapped_column(String(200), nullable=False)
|
||
|
|
informations: Mapped[str | None] = mapped_column(Text)
|
||
|
|
ordre_affichage: Mapped[int] = mapped_column(Integer, default=99)
|
||
|
|
cree_le: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class PosteTache(Base):
|
||
|
|
"""Association poste ↔ tâche (N:N). Une tâche peut être affectée à plusieurs postes."""
|
||
|
|
__tablename__ = "postes_taches"
|
||
|
|
|
||
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
||
|
|
poste_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("postes.id"), nullable=False)
|
||
|
|
tache_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("taches.id"), nullable=False)
|
||
|
|
cree_le: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||
|
|
)
|