本文整理汇总了Python中models.Comment.sender_name方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.sender_name方法的具体用法?Python Comment.sender_name怎么用?Python Comment.sender_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.sender_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comment_add
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import sender_name [as 别名]
def comment_add():
log('发送评论')
user_now = current_user()
form = request.get_json()
print('form, ', form)
c = Comment(form)
blog_id = form.get('blog_id', '')
# 设置是谁发的
c.sender_name = user_now.username
c.blog = Blog.query.filter_by(id=blog_id).first()
# 保存到数据库
c.save()
blog = c.blog
blog.com_count = len(Comment.query.filter_by(blog_id=blog.id).all())
blog.save()
log('写评论')
status = {
'content': c.content,
'sender_name': c.sender_name,
'created_time': formatted_time(c.created_time),
'id': c.id,
}
r = json.dumps(status, ensure_ascii=False)
print('r, ', r)
return r
示例2: reply_act
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import sender_name [as 别名]
def reply_act(comment_id):
user_now = current_user()
c = Comment(request.form)
c.sender_name = user_now.username
c.reply_id = comment_id
comment = Comment.query.filter_by(id=comment_id).first()
c.blog_id = comment.blog.id
c.save()
blog = c.blog
blog.com_count = len(Comment.query.filter_by(blog_id=blog.id).all())
blog.save()
log('回复评论成功')
return redirect(url_for('reply_view', comment_id=comment_id))
示例3: comment_add
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import sender_name [as 别名]
def comment_add(blog_id):
user_now = current_user()
c = Comment(request.form)
# 设置是谁发的
c.sender_name = user_now.username
c.blog = Blog.query.filter_by(id=blog_id).first()
# 保存到数据库
c.save()
blog = c.blog
blog.com_count = len(Comment.query.filter_by(blog_id=blog.id).all())
blog.save()
log('写评论')
return redirect(url_for('blog_view', blog_id=blog_id))