修复无法删除Local App记录的问题
This commit is contained in:
parent
81ffc451af
commit
8278c50c1e
@ -238,11 +238,19 @@ def create_local_app(app_data):
|
||||
def update_local_app(name, app_data):
|
||||
"""更新本地应用"""
|
||||
|
||||
team = get_current_team()
|
||||
if not team:
|
||||
return {"success": False, "message": "未找到当前团队信息"}
|
||||
|
||||
if not jingrow.db.exists("Local App", name):
|
||||
return {"success": False, "message": "应用不存在"}
|
||||
|
||||
app = jingrow.get_pg("Local App", name)
|
||||
|
||||
# 验证权限:只能更新自己团队的应用
|
||||
if app.team != team:
|
||||
return {"success": False, "message": "您没有权限操作此应用"}
|
||||
|
||||
# 解析 JSON 数据
|
||||
if isinstance(app_data, str):
|
||||
try:
|
||||
@ -262,7 +270,8 @@ def update_local_app(name, app_data):
|
||||
if not updated_fields:
|
||||
return {"success": False, "message": "没有有效的字段被更新"}
|
||||
|
||||
app.save()
|
||||
# 使用 ignore_permissions=True 因为我们已经手动验证了团队权限
|
||||
app.save(ignore_permissions=True)
|
||||
return {"success": True, "name": app.name, "updated_fields": updated_fields, "message": "应用更新成功"}
|
||||
|
||||
|
||||
@ -270,11 +279,21 @@ def update_local_app(name, app_data):
|
||||
def delete_local_app(name):
|
||||
"""删除本地应用"""
|
||||
|
||||
team = get_current_team()
|
||||
if not team:
|
||||
return {"success": False, "message": "未找到当前团队信息"}
|
||||
|
||||
if not jingrow.db.exists("Local App", name):
|
||||
return {"success": False, "message": "应用不存在"}
|
||||
|
||||
app = jingrow.get_pg("Local App", name)
|
||||
app.delete()
|
||||
|
||||
# 验证权限:只能删除自己团队的应用
|
||||
if app.team != team:
|
||||
return {"success": False, "message": "您没有权限操作此应用"}
|
||||
|
||||
# 使用 ignore_permissions=True 因为我们已经手动验证了团队权限
|
||||
app.delete(ignore_permissions=True)
|
||||
|
||||
return {"success": True, "message": "应用删除成功"}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user