feat: 方案待定制可编辑+通知去定制按钮+权限修复
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 50s
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 50s
- 会员等待中可修改健康需求,修改后通知老师 - 通知里方案请求显示"去定制"按钮跳转用户管理 - 后端: 方案owner可更新health_desc,teacher可改title/status Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1659,12 +1659,21 @@ def update_oil_plan(plan_id: int, body: dict, user=Depends(get_current_user)):
|
||||
if not plan:
|
||||
conn.close()
|
||||
raise HTTPException(404, "方案不存在")
|
||||
if plan["teacher_id"] != user["id"] and user["role"] != "admin":
|
||||
is_teacher = plan["teacher_id"] == user["id"] or user["role"] == "admin"
|
||||
is_owner = plan["user_id"] == user["id"]
|
||||
if not is_teacher and not is_owner:
|
||||
conn.close()
|
||||
raise HTTPException(403, "无权操作")
|
||||
if "title" in body:
|
||||
if "health_desc" in body and is_owner:
|
||||
conn.execute("UPDATE oil_plans SET health_desc = ? WHERE id = ?", (body["health_desc"], plan_id))
|
||||
who = user.get("display_name") or user["username"]
|
||||
conn.execute(
|
||||
"INSERT INTO notifications (target_role, title, body, target_user_id) VALUES (?, ?, ?, ?)",
|
||||
("admin", "📋 方案需求已更新", f"{who} 更新了健康需求:{body['health_desc'][:50]}", plan["teacher_id"])
|
||||
)
|
||||
if "title" in body and is_teacher:
|
||||
conn.execute("UPDATE oil_plans SET title = ? WHERE id = ?", (body["title"], plan_id))
|
||||
if "status" in body:
|
||||
if "status" in body and is_teacher:
|
||||
old_status = plan["status"]
|
||||
conn.execute("UPDATE oil_plans SET status = ? WHERE id = ?", (body["status"], plan_id))
|
||||
if body["status"] == "active" and old_status != "active":
|
||||
|
||||
Reference in New Issue
Block a user