Skip to content

Commit

Permalink
canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
Feiue committed Sep 4, 2024
1 parent b551707 commit 5ea57cc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/apps/canvas_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ def save():
if not UserCanvasService.save(**req):
return get_data_error_result(retmsg="Fail to save canvas.")
else:
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)
UserCanvasService.update_by_id(req["id"], req)

return get_json_result(data=req)


Expand All @@ -91,6 +94,10 @@ def run():
e, cvs = UserCanvasService.get_by_id(req["id"])
if not e:
return get_data_error_result(retmsg="canvas not found.")
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)

if not isinstance(cvs.dsl, str):
cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False)
Expand Down Expand Up @@ -157,6 +164,10 @@ def reset():
e, user_canvas = UserCanvasService.get_by_id(req["id"])
if not e:
return get_data_error_result(retmsg="canvas not found.")
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)

canvas = Canvas(json.dumps(user_canvas.dsl), current_user.id)
canvas.reset()
Expand Down

0 comments on commit 5ea57cc

Please sign in to comment.