本文整理汇总了Python中model.Comment.vote_count方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.vote_count方法的具体用法?Python Comment.vote_count怎么用?Python Comment.vote_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.vote_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_comment
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import vote_count [as 别名]
def add_comment():
comment = request.form.get("comment")
question_id = request.form.get("question_id")
question_info = Question.query.get(question_id)
question_author = User.query.filter(User.user_id == question_info.user_id).first()
date_string = datetime.today().strftime('%Y-%m-%d')
commented_item = Comment(user_id = session["user_id"], comment_timestamp = date_string, question_id = question_id, comment = comment)
db.session.add(commented_item)
db.session.commit()
comment_author = User.query.filter(User.user_id == commented_item.user_id).first()
comment_auth_image = comment_author.images[0]
result = {'comment_id': commented_item.comment_id,
'vote': commented_item.vote_count(),
'comment_author': comment_author.username,
'comment_auth_image':comment_auth_image.image,
'comment_timestamp': commented_item.comment_timestamp,
'user_id': comment_author.user_id}
notify_author_comment(commented_item.comment, question_author.email, question_author.username, question_info.question, question_info.title_question, comment_author.username)
return jsonify(result)