kin: KIN-UI-003 Консистентная обработка ошибок в del() — использовать throwApiError

This commit is contained in:
Gros Frumos 2026-03-16 17:44:49 +02:00
parent fc13245c93
commit 531275e4ce
5 changed files with 112 additions and 35 deletions

View file

@ -14,7 +14,7 @@ sys.path.insert(0, str(Path(__file__).parent.parent))
from fastapi import FastAPI, HTTPException, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, FileResponse
from fastapi.responses import JSONResponse, FileResponse, Response
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel, model_validator
@ -247,6 +247,19 @@ def patch_project(project_id: str, body: ProjectPatch):
return p
@app.delete("/api/projects/{project_id}", status_code=204)
def delete_project(project_id: str):
"""Delete a project and all its related data (tasks, decisions, phases, logs)."""
conn = get_conn()
p = models.get_project(conn, project_id)
if not p:
conn.close()
raise HTTPException(404, f"Project '{project_id}' not found")
models.delete_project(conn, project_id)
conn.close()
return Response(status_code=204)
@app.post("/api/projects/{project_id}/sync/obsidian")
def sync_obsidian_endpoint(project_id: str):
"""Запускает двусторонний Obsidian sync для проекта."""