fix: admins können jetzt alle Prompts sehen und bearbeiten
All checks were successful
Deploy Development / deploy (push) Successful in 57s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

- /api/prompts checkt nun ob User admin ist
- Admins sehen ALLE Prompts (inkl. pipeline_ und inaktive)
- Normale User sehen nur aktive Einzelanalysen (wie bisher)
- Frontend (Analysis.jsx) zeigt Pipeline-Prompts bereits korrekt:
  * Gruppiert nach "Einzelanalysen" und "Mehrstufige Pipeline"
  * JSON-Prompts (Stage 1) mit oranger Border und Badge
  * Warnung über JSON-Format bereits vorhanden
- CSS-Variablen --warn, --warn-bg, --warn-text bereits definiert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-19 06:28:48 +01:00
parent 115d975335
commit 518e417b1d

View File

@ -1063,10 +1063,22 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
@app.get("/api/prompts") @app.get("/api/prompts")
def list_prompts(session: dict=Depends(require_auth)): def list_prompts(session: dict=Depends(require_auth)):
"""List all available AI prompts.""" """
List AI prompts.
- Admins: see ALL prompts (including pipeline and inactive)
- Users: see only active single-analysis prompts
"""
with get_db() as conn: with get_db() as conn:
cur = get_cursor(conn) cur = get_cursor(conn)
cur.execute("SELECT * FROM ai_prompts WHERE active=true AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order") is_admin = session.get('role') == 'admin'
if is_admin:
# Admin sees everything
cur.execute("SELECT * FROM ai_prompts ORDER BY sort_order, slug")
else:
# Users see only active, non-pipeline prompts
cur.execute("SELECT * FROM ai_prompts WHERE active=true AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order")
return [r2d(r) for r in cur.fetchall()] return [r2d(r) for r in cur.fetchall()]
@app.put("/api/prompts/{prompt_id}") @app.put("/api/prompts/{prompt_id}")