Backend: 7 nouveaux endpoints (advance, assign, revoke, create-vote-session), services enrichis avec creation de sessions de vote, assignation de mandataire et revocation. 35 nouveaux tests (104 total). Frontend: store mandates, page cadrage decisions, detail mandats, composants DecisionWorkflow, DecisionCadrage, DecisionCard, MandateTimeline, MandateCard. Documentation mise a jour. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
3.1 KiB
Python
106 lines
3.1 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)
|
|
description: str | None = None
|
|
mandate_type: str = Field(..., max_length=64, description="techcomm, smith, custom")
|
|
decision_id: UUID | 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
|
|
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
|
|
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")
|