diff --git a/backend/main.py b/backend/main.py index 1b50276..05fa945 100644 --- a/backend/main.py +++ b/backend/main.py @@ -781,8 +781,14 @@ def create_recipe(recipe: RecipeIn, user=Depends(get_current_user)): raise HTTPException(401, "请先登录") conn = get_db() c = conn.cursor() + # Senior editors adding directly to public library: set owner to admin so everyone can see + owner_id = user["id"] + if user["role"] in ("senior_editor",): + admin = c.execute("SELECT id FROM users WHERE role = 'admin' LIMIT 1").fetchone() + if admin: + owner_id = admin["id"] c.execute("INSERT INTO recipes (name, note, owner_id) VALUES (?, ?, ?)", - (recipe.name, recipe.note, user["id"])) + (recipe.name, recipe.note, owner_id)) rid = c.lastrowid for ing in recipe.ingredients: c.execute( @@ -793,8 +799,8 @@ def create_recipe(recipe: RecipeIn, user=Depends(get_current_user)): c.execute("INSERT OR IGNORE INTO tags (name) VALUES (?)", (tag,)) c.execute("INSERT OR IGNORE INTO recipe_tags (recipe_id, tag_name) VALUES (?, ?)", (rid, tag)) log_audit(conn, user["id"], "create_recipe", "recipe", rid, recipe.name) - # Notify admin only when non-admin creates a recipe - if user["role"] != "admin": + # Notify admin when non-admin/non-senior_editor creates a recipe (needs review) + if user["role"] not in ("admin", "senior_editor"): who = user.get("display_name") or user["username"] conn.execute( "INSERT INTO notifications (target_role, title, body) VALUES (?, ?, ?)", diff --git a/frontend/src/views/OilReference.vue b/frontend/src/views/OilReference.vue index e58b170..db84abb 100644 --- a/frontend/src/views/OilReference.vue +++ b/frontend/src/views/OilReference.vue @@ -98,15 +98,15 @@ - + - + -
+
@@ -152,7 +152,7 @@
-
+