forked from yvv/decision
3ba9c43ce3
- Mandate model : champ origin (contexte/déclencheur) + migration
- MandateCreate schema : origin, starts_at, ends_at
- mandates/new.vue : wizard complet
· Étape 1 : type · nom · origine · description · durée (relative ou dates)
· Étape 2 : auto-désignation (ratification) ou désignation collective
· Étape 3 : boîte à outils — sans/avec candidature, 6 modalités,
paramètres configurables (durée, quorum, seuil, slider+input)
· Étape 4 : récap + génération automatique des étapes du mandat
- Tous les boutons "Nouveau mandat" pointent vers /mandates/new
- decisions/new.vue : "Demander un mandat" → /mandates/new
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
111 lines
3.2 KiB
Python
111 lines
3.2 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
# ── Mandate Step ─────────────────────────────────────────────────
|
|
|
|
|
|
class MandateStepCreate(BaseModel):
|
|
"""Payload for creating a step within a mandate process."""
|
|
|
|
step_order: int = Field(..., ge=0)
|
|
step_type: str = Field(
|
|
...,
|
|
max_length=32,
|
|
description="formulation, candidacy, vote, assignment, reporting, completion, revocation",
|
|
)
|
|
title: str | None = Field(default=None, max_length=256)
|
|
description: str | None = None
|
|
|
|
|
|
class MandateStepOut(BaseModel):
|
|
"""Full mandate step representation."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
mandate_id: UUID
|
|
step_order: int
|
|
step_type: str
|
|
title: str | None = None
|
|
description: str | None = None
|
|
status: str
|
|
vote_session_id: UUID | None = None
|
|
outcome: str | None = None
|
|
created_at: datetime
|
|
|
|
|
|
# ── Mandate ──────────────────────────────────────────────────────
|
|
|
|
|
|
class MandateCreate(BaseModel):
|
|
"""Payload for creating a new mandate."""
|
|
|
|
title: str = Field(..., min_length=1, max_length=256)
|
|
origin: str | None = None
|
|
description: str | None = None
|
|
mandate_type: str = Field(..., max_length=64, description="techcomm, smith, custom")
|
|
decision_id: UUID | None = None
|
|
starts_at: datetime | None = None
|
|
ends_at: datetime | None = None
|
|
|
|
|
|
class MandateUpdate(BaseModel):
|
|
"""Partial update for a mandate."""
|
|
|
|
title: str | None = Field(default=None, max_length=256)
|
|
description: str | None = None
|
|
mandate_type: str | None = Field(default=None, max_length=64)
|
|
decision_id: UUID | None = None
|
|
|
|
|
|
class MandateAssignRequest(BaseModel):
|
|
"""Request body for assigning a mandatee to a mandate."""
|
|
|
|
mandatee_id: UUID = Field(..., description="ID de l'identite Duniter du mandataire")
|
|
|
|
|
|
class MandateOut(BaseModel):
|
|
"""Full mandate representation returned by the API."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
title: str
|
|
origin: str | None = None
|
|
description: str | None = None
|
|
mandate_type: str
|
|
status: str
|
|
mandatee_id: UUID | None = None
|
|
decision_id: UUID | None = None
|
|
starts_at: datetime | None = None
|
|
ends_at: datetime | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
steps: list[MandateStepOut] = Field(default_factory=list)
|
|
|
|
|
|
class MandateAdvanceOut(BaseModel):
|
|
"""Output after advancing a mandate through its workflow."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
title: str
|
|
origin: str | None = None
|
|
description: str | None = None
|
|
mandate_type: str
|
|
status: str
|
|
mandatee_id: UUID | None = None
|
|
decision_id: UUID | None = None
|
|
starts_at: datetime | None = None
|
|
ends_at: datetime | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
steps: list[MandateStepOut] = Field(default_factory=list)
|
|
message: str = Field(..., description="Message decrivant l'avancement effectue")
|