feat: allow deleting draft agreements while keeping approved read-only

This commit is contained in:
Арсентьев Александр
2026-09-28 21:55:29 +03:00
parent 2821208c65
commit 1b5bad0baf
9 changed files with 933 additions and 2 deletions
+14
View File
@@ -13,6 +13,7 @@ from app.services.agreement_items import (
add_existing_item,
add_new_item,
available_work_items,
delete_draft_agreement,
delete_draft_item,
update_draft_item,
)
@@ -379,6 +380,19 @@ async def remove_item(project_id: int, agreement_id: int, line_id: int,
return _detail_response(request, db, project_obj, agreement, str(exc), 409)
@router.post("/{project_id}/agreements/{agreement_id}/delete")
async def delete_agreement(project_id: int, agreement_id: int, db: Session = Depends(get_db)):
_project(db, project_id)
agreement = _agreement(db, project_id, agreement_id)
try:
delete_draft_agreement(db, agreement)
except ValueError as exc:
raise HTTPException(status_code=409, detail=str(exc)) from exc
return RedirectResponse(
f"/projects/{project_id}/agreements?deleted=1", status_code=303
)
@router.post("/{project_id}/agreements/{agreement_id}/approve")
async def confirm_approval(project_id: int, agreement_id: int, request: Request,
db: Session = Depends(get_db)):