def show_comments_of_post(post_id): post = Post.get(post_id) _comments = "" for comment in post.comments: _comments += "<li>" + \ "<div id='comment_box'>" + \ "<a id='comment_author' href='/user/"+comment["user"]+"'>" + \ comment["user"] + \ "</a>" + \ "<p id='comment_text'>" + \ comment["comment_text"] + \ "</p>" + \ "</div>" + \ "</li>" comment_list = "<ul id='comment_list'>" + _comments + "</ul>" return comment_list + render_template("comments.html")
def count_comments(post_id): post = Post.get(post_id) return len(post.comments)