Kakashiix26 commited on
Commit
7f50e4d
·
verified ·
1 Parent(s): cfba014

add DELETE /projects/{id}

Browse files
api/__pycache__/projects.cpython-314.pyc CHANGED
Binary files a/api/__pycache__/projects.cpython-314.pyc and b/api/__pycache__/projects.cpython-314.pyc differ
 
api/projects.py CHANGED
@@ -155,3 +155,22 @@ def update_history(
155
  row.oncall_log = body.oncall_log
156
  db.commit()
157
  return {"ok": True}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  row.oncall_log = body.oncall_log
156
  db.commit()
157
  return {"ok": True}
158
+
159
+
160
+ @router.delete("/{project_id}")
161
+ def delete_project(project_id: str, current_user: User = Depends(get_current_user)) -> dict:
162
+ """Delete a project the authed user owns. 404 (not 403) for missing or
163
+ someone else's project — we don't reveal that another user's id exists.
164
+ Idempotent from the client's view: the chat/oncall_log live inline on the
165
+ row, so deleting the row removes the whole session."""
166
+ try:
167
+ pid = uuid.UUID(project_id)
168
+ except ValueError:
169
+ raise HTTPException(status_code=404, detail="Project not found")
170
+ with SessionLocal() as db:
171
+ row = db.get(Project, pid)
172
+ if not row or row.user_id != current_user.id:
173
+ raise HTTPException(status_code=404, detail="Project not found")
174
+ db.delete(row)
175
+ db.commit()
176
+ return {"ok": True}