2026-05-15 16:41:17 -04:00
|
|
|
"""Schémas Phase 8 — Votes et sondages."""
|
2026-03-04 14:01:00 -05:00
|
|
|
from pydantic import BaseModel
|
2026-05-15 16:41:17 -04:00
|
|
|
from datetime import datetime
|
2026-03-04 14:01:00 -05:00
|
|
|
from uuid import UUID
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ── G6 Lancer un sondage ──
|
|
|
|
|
class OptionCreate(BaseModel):
|
|
|
|
|
texte: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SondageCreate(BaseModel):
|
|
|
|
|
titre: str
|
|
|
|
|
description: Optional[str] = None
|
|
|
|
|
type: str = "oui_non" # oui_non, choix_multiple, unanimite
|
|
|
|
|
date_ouverture: datetime
|
|
|
|
|
date_fermeture: datetime
|
|
|
|
|
options: list[OptionCreate] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OptionOut(BaseModel):
|
|
|
|
|
id: UUID
|
|
|
|
|
texte: str
|
|
|
|
|
ordre: int
|
|
|
|
|
nb_votes: int = 0
|
|
|
|
|
|
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SondageOut(BaseModel):
|
|
|
|
|
id: UUID
|
|
|
|
|
titre: str
|
|
|
|
|
description: Optional[str] = None
|
|
|
|
|
type: str
|
|
|
|
|
cree_par_prenom: Optional[str] = None
|
|
|
|
|
date_ouverture: datetime
|
|
|
|
|
date_fermeture: datetime
|
|
|
|
|
statut: str
|
|
|
|
|
options: list[OptionOut] = []
|
|
|
|
|
total_votes: int = 0
|
|
|
|
|
a_vote: bool = False # le membre courant a-t-il voté?
|
|
|
|
|
|
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SondageUpdate(BaseModel):
|
|
|
|
|
statut: Optional[str] = None # ouvert, ferme
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ── C6 Voter ──
|
|
|
|
|
class VoteCreate(BaseModel):
|
|
|
|
|
option_id: UUID
|
|
|
|
|
|