Add unpublish endpoint to moderation router

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
bernatsampera
2026-08-09 02:36:26 +02:00
co-authored by Claude Opus 4.6
parent 061972e91a
commit 9a4ada1614
+13
View File
@@ -76,3 +76,16 @@ def reject(workflow_id: str, session: Session = Depends(get_session)):
template.reviewed_at = datetime.now(timezone.utc)
session.commit()
return {"id": workflow_id, "status": REJECTED}
@router.post("/{workflow_id}/unpublish", dependencies=[Depends(require_admin)])
def unpublish(workflow_id: str, session: Session = Depends(get_session)):
template = session.scalars(
select(Template).where(Template.id == workflow_id, Template.status == APPROVED)
).first()
if template is None:
raise HTTPException(status_code=404, detail="no approved workflow with this id")
template.status = REJECTED
template.reviewed_at = datetime.now(timezone.utc)
session.commit()
return {"id": workflow_id, "status": REJECTED}