ソースを参照

fix: 修改删除博文的反馈错误

SongZihuan 2 年 前
コミット
24233462b7
1 ファイル変更9 行追加4 行削除
  1. 9 4
      app/docx.py

+ 9 - 4
app/docx.py

@@ -312,13 +312,18 @@ def comment_page():
 @app.role_required("DeleteComment", "delete comment")
 def delete_comment_page():
     comment_id = request.args.get("comment", 1, type=int)
-    if Comment(comment_id).delete():
+    comment = Comment(comment_id)
+    blog_id = comment.blog.id
+    if blog_id == -1:
+        abort(404)
+
+    if comment.delete():
         app.HBlogFlask.print_sys_opt_success_log("delete comment")
-        flash("博文评论成功")
+        flash("博文评论删除成功")
     else:
         app.HBlogFlask.print_sys_opt_fail_log("delete comment")
-        flash("博文评论失败")
-    return redirect(url_for("docx.docx_page", page=1))
+        flash("博文评论删除失败")
+    return redirect(url_for("docx.article_page", blog=blog_id))
 
 
 @docx.context_processor