Plateforme de decisions collectives pour Duniter/G1. Backend FastAPI async + PostgreSQL (14 tables, 8 routers, 6 services, moteur de vote avec formule d'inertie WoT/Smith/TechComm). Frontend Nuxt 4 + Nuxt UI v3 + Pinia (9 pages, 5 stores). Infrastructure Docker + Woodpecker CI + Traefik. Documentation technique et utilisateur (15 fichiers). Seed : Licence G1, Engagement Forgeron v2.0.0, 4 protocoles de vote. 30 tests unitaires (formules, mode params, vote nuance) -- tous verts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
104 lines
3.2 KiB
Python
104 lines
3.2 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
# ── Document ─────────────────────────────────────────────────────
|
|
|
|
|
|
class DocumentCreate(BaseModel):
|
|
"""Payload for creating a new reference document."""
|
|
|
|
slug: str = Field(..., min_length=1, max_length=128)
|
|
title: str = Field(..., min_length=1, max_length=256)
|
|
doc_type: str = Field(..., max_length=64, description="licence, engagement, reglement, constitution")
|
|
description: str | None = None
|
|
version: str | None = Field(default="0.1.0", max_length=32)
|
|
|
|
|
|
class DocumentUpdate(BaseModel):
|
|
"""Partial update for a document."""
|
|
|
|
title: str | None = Field(default=None, max_length=256)
|
|
status: str | None = Field(default=None, max_length=32)
|
|
description: str | None = None
|
|
version: str | None = Field(default=None, max_length=32)
|
|
|
|
|
|
class DocumentOut(BaseModel):
|
|
"""Full document representation returned by the API."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
slug: str
|
|
title: str
|
|
doc_type: str
|
|
version: str
|
|
status: str
|
|
description: str | None = None
|
|
ipfs_cid: str | None = None
|
|
chain_anchor: str | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
items_count: int = Field(default=0, description="Number of items in this document")
|
|
|
|
|
|
# ── Document Item ────────────────────────────────────────────────
|
|
|
|
|
|
class DocumentItemCreate(BaseModel):
|
|
"""Payload for creating a document item (clause, rule, etc.)."""
|
|
|
|
position: str = Field(..., max_length=16, description='Hierarchical position e.g. "1", "1.1", "3.2"')
|
|
item_type: str = Field(default="clause", max_length=32, description="clause, rule, verification, preamble, section")
|
|
title: str | None = Field(default=None, max_length=256)
|
|
current_text: str = Field(..., min_length=1)
|
|
voting_protocol_id: UUID | None = None
|
|
|
|
|
|
class DocumentItemOut(BaseModel):
|
|
"""Full document item representation."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
document_id: UUID
|
|
position: str
|
|
item_type: str
|
|
title: str | None = None
|
|
current_text: str
|
|
voting_protocol_id: UUID | None = None
|
|
sort_order: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
# ── Item Version ─────────────────────────────────────────────────
|
|
|
|
|
|
class ItemVersionCreate(BaseModel):
|
|
"""Payload for proposing a new version of a document item."""
|
|
|
|
proposed_text: str = Field(..., min_length=1)
|
|
rationale: str | None = None
|
|
|
|
|
|
class ItemVersionOut(BaseModel):
|
|
"""Full item version representation."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
item_id: UUID
|
|
proposed_text: str
|
|
diff_text: str | None = None
|
|
rationale: str | None = None
|
|
status: str
|
|
decision_id: UUID | None = None
|
|
proposed_by_id: UUID | None = None
|
|
created_at: datetime
|