BE-PR-005: Add Essential schema definitions (create/update/response) and ProposalDetailResponse with nested essentials
This commit is contained in:
@@ -302,6 +302,57 @@ class ProposalResponse(ProposalBase):
|
|||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Essential schemas (under Proposal)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class EssentialTypeEnum(str, Enum):
|
||||||
|
FEATURE = "feature"
|
||||||
|
IMPROVEMENT = "improvement"
|
||||||
|
REFACTOR = "refactor"
|
||||||
|
|
||||||
|
|
||||||
|
class EssentialBase(BaseModel):
|
||||||
|
title: str
|
||||||
|
type: EssentialTypeEnum
|
||||||
|
description: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
class EssentialCreate(EssentialBase):
|
||||||
|
"""Create a new Essential under a Proposal.
|
||||||
|
|
||||||
|
``proposal_id`` is inferred from the URL path, not the body.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EssentialUpdate(BaseModel):
|
||||||
|
title: Optional[str] = None
|
||||||
|
type: Optional[EssentialTypeEnum] = None
|
||||||
|
description: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
class EssentialResponse(EssentialBase):
|
||||||
|
id: int
|
||||||
|
essential_code: str
|
||||||
|
proposal_id: int
|
||||||
|
created_by_id: Optional[int] = None
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: Optional[datetime] = None
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
|
class ProposalDetailResponse(ProposalResponse):
|
||||||
|
"""Extended Proposal response that embeds its Essential list."""
|
||||||
|
|
||||||
|
essentials: List[EssentialResponse] = []
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
# Backward-compatible aliases
|
# Backward-compatible aliases
|
||||||
ProposeStatusEnum = ProposalStatusEnum
|
ProposeStatusEnum = ProposalStatusEnum
|
||||||
ProposeBase = ProposalBase
|
ProposeBase = ProposalBase
|
||||||
|
|||||||
Reference in New Issue
Block a user