From 6752b27f9995fea51854dd9e0f85082a6b623e66 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Sun, 12 Apr 2026 10:14:06 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20admin=E8=B4=A1=E7=8C=AE=E6=95=B0?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=8C=85=E5=90=AB=E6=89=80=E6=9C=89=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E9=85=8D=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/main.py b/backend/main.py index 9a96f91..c42e324 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1644,11 +1644,14 @@ def my_contribution(user=Depends(get_current_user)): (f'%"from_user": "{display}"%',) ).fetchall() adopted_names = list(set(r["target_name"] for r in adopted_rows if r["target_name"])) - # pending: recipes still owned by user in public library - pending_rows = conn.execute( - "SELECT name FROM recipes WHERE owner_id = ?", (user["id"],) - ).fetchall() - pending_names = [r["name"] for r in pending_rows] + # pending: recipes still owned by user in public library (skip admin — admin owns all public recipes) + if user.get("role") == "admin": + pending_names = [] + else: + pending_rows = conn.execute( + "SELECT name FROM recipes WHERE owner_id = ?", (user["id"],) + ).fetchall() + pending_names = [r["name"] for r in pending_rows] # rejected: unique recipe names rejected (not already adopted or pending) rejected_rows = conn.execute( "SELECT DISTINCT target_name FROM audit_log WHERE action = 'reject_recipe' AND detail LIKE ?",