feat(backend): harden draft, pricing and publish contracts
- unify typed API errors across draft, pricing and publish flows - add stale draft and publish-state mutation guards - add publish readiness contract and guarded publish flow - add sellability reason codes to test seat preview - add pricing diagnostics and strengthen snapshot/publish lifecycle consistency
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from app.repositories.scheme_versions import get_current_scheme_version
|
||||
from app.repositories.schemes import get_scheme_record_by_scheme_id
|
||||
from app.services.api_errors import raise_conflict
|
||||
@@ -29,9 +27,14 @@ async def get_current_draft_context(
|
||||
)
|
||||
|
||||
if version.status != "draft" or scheme.status != "draft":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail="Current scheme version is not editable because it is not in draft state",
|
||||
raise_conflict(
|
||||
code="draft_not_editable",
|
||||
message="Current scheme version is not editable because it is not in draft state",
|
||||
details={
|
||||
"scheme_status": scheme.status,
|
||||
"scheme_version_status": version.status,
|
||||
"actual_scheme_version_id": version.scheme_version_id,
|
||||
},
|
||||
)
|
||||
|
||||
if expected_scheme_version_id and expected_scheme_version_id != version.scheme_version_id:
|
||||
|
||||
Reference in New Issue
Block a user