Esempio n. 1
0
def add_comment_lib(self, content, article_id):

    article = Article.by_id(article_id)
    if article is None:
        return {'status': False, 'msg': '文章不存在'}

    comment = Comment()
    comment.content = content
    comment.article_id = article.id
    comment.user_id = self.current_user.id
    self.db.add(comment)
    self.db.commit()
    return {'status': True, 'msg': '评论成功'}
def add_comment_lib(self, content, article_id):
    '''添加评论'''
    if content == '':
        return {'status': False, 'msg': '请输入评论!'}

    article = Article.by_id(article_id)
    if article is None:
        return {'status': False, 'msg': '文档不存在!'}

    comment = Comment()
    comment.content = content
    comment.article_id = article.id
    comment.user_id = self.current_user.id
    self.db.add(comment)
    self.db.commit()
    return {'status': True, 'msg': '评论成功!'}