|
@@ -1,20 +1,34 @@
|
|
-from flask import Blueprint, render_template, request
|
|
|
|
|
|
+from flask import Blueprint, render_template, request, abort
|
|
|
|
|
|
from .db import Comment
|
|
from .db import Comment
|
|
-from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
comment = Blueprint("comment", __name__)
|
|
comment = Blueprint("comment", __name__)
|
|
|
|
|
|
|
|
|
|
|
|
+@comment.route("/")
|
|
|
|
+def comment_page():
|
|
|
|
+ comment_id = request.args.get("comment_id", -1, type=int)
|
|
|
|
+ if comment_id == -1:
|
|
|
|
+ return abort(404)
|
|
|
|
+ cm: Comment = Comment.query.filter_by(id=comment_id).first()
|
|
|
|
+ if cm:
|
|
|
|
+ return render_template("comment/comment.html",
|
|
|
|
+ comment=cm,
|
|
|
|
+ comment_son=cm.son)
|
|
|
|
+ return abort(404)
|
|
|
|
+
|
|
|
|
+
|
|
@comment.route("/all")
|
|
@comment.route("/all")
|
|
def list_all_page():
|
|
def list_all_page():
|
|
page = request.args.get("page", 1, type=int)
|
|
page = request.args.get("page", 1, type=int)
|
|
pagination = (Comment.query
|
|
pagination = (Comment.query
|
|
.filter(Comment.title != None).filter(Comment.father_id == None)
|
|
.filter(Comment.title != None).filter(Comment.father_id == None)
|
|
.order_by(Comment.create_time.desc(), Comment.title.desc())
|
|
.order_by(Comment.create_time.desc(), Comment.title.desc())
|
|
- .paginate(page=page, per_page=20, error_out=False))
|
|
|
|
|
|
+ .paginate(page=page, per_page=8, error_out=False))
|
|
return render_template("comment/list.html",
|
|
return render_template("comment/list.html",
|
|
page=page,
|
|
page=page,
|
|
items=pagination.items,
|
|
items=pagination.items,
|
|
- pagination=pagination)
|
|
|
|
|
|
+ pagination=pagination,
|
|
|
|
+ archive_name="全部讨论",
|
|
|
|
+ archive_describe="罗列了本站所有的讨论")
|