本文整理汇总了Python中models.comment.Comment.pic方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.pic方法的具体用法?Python Comment.pic怎么用?Python Comment.pic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.pic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comment_request_impl
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import pic [as 别名]
def comment_request_impl(args):
try:
author = user_from_token(args['token'])
post = post_from_id(author, args['post_id'])
comment = Comment(args['content'])
post.comments.append(comment)
author.comments.append(comment)
post.add_hot(5, None)
if args.has_key("picture") and args['picture'] is not None:
output = s3_upload(args['picture'])
url = 'https://{}.s3.amazonaws.com/{}'.format(os.environ['S3_BUCKET_NAME'], output)
comment.pic = url
db.session.commit()
#send notification to author
send_notification_for_user_commenting_on_post(device_token=post.user.device_token,
user_id=author.id,
user_pic=author.pic,
comment_id=comment.id,
nickname=author.nickname,
post_id=post.id,
platform=post.user.platform)
return Response(True, "Comment Succeded", CommentSchema().dumps(comment).data).output()
except Exception as exception:
return Response(False, str(exception), None).output()