rubric-ai / frontend /api_routes.py
itslikethisnow's picture
three stages complete
a43aaf6
"""API routes for frontend operations."""
import json
from nicegui import app
from frontend.ui import get_authed_client
@app.post('/api/project/update-status')
async def update_project_status(request):
"""
Update project status for stage navigation.
Request body:
{
"project_id": "uuid",
"status": "Stage 1: Grouping" | "Stage 2: Building" | "Stage 3: Scoring"
}
"""
try:
# Parse JSON from request body
body = await request.body()
data = json.loads(body.decode('utf-8'))
project_id = data.get('project_id')
new_status = data.get('status')
print(f"Update status request: project_id={project_id}, status={new_status}")
if not project_id or not new_status:
return {'error': 'Missing project_id or status'}, 400
# Get authenticated client
auth_client = get_authed_client()
if not auth_client:
return {'error': 'Not authenticated'}, 401
# Update project status
result = auth_client.table("projects") \
.update({"status": new_status}) \
.eq("id", project_id) \
.execute()
print(f"Update successful")
return {'success': True}
except Exception as e:
print(f"Error updating project status: {e}")
import traceback
traceback.print_exc()
return {'error': str(e)}, 500