コード例 #1
0
ファイル: article_libs.py プロジェクト: cyc41247293/OA-System
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': '评论成功'}
コード例 #2
0
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': '评论成功!'}
コード例 #3
0
ファイル: article_libs.py プロジェクト: tomsue/oasystem
def article_list_lib(self):
    ''' 显示文档首页 需要的数据'''
    articles = Article.all_createtime_desc()
    comments = Comment.all_createtime_desc()
    # tags = Tag.all()
    # categorys = Category.all()
    tags, categorys = get_tags_categorys_lib(self)
    return articles, comments, categorys, tags
コード例 #4
0
ファイル: article_libs.py プロジェクト: cyc41247293/OA-System
def article_search_lib(self, category_id, tag_id):
    if tag_id != '':
        tag = Tag.by_id(tag_id)
        articles = tag.articles
    if category_id != '':
        category = Category.by_id(category_id)
        articles = category.articles

    tags, categorys = get_tags_categorys_lib(self)
    comments = Comment.all_createtime_desc()
    return articles, comments, categorys, tags
コード例 #5
0
def article_search_list_lib(self, category_id, tag_id):
    '''查找'''
    if category_id != '':
        category = Category.by_id(category_id)  # 获取分类
        articles = category.articles  # 获取该分类的文章
    if tag_id != '':
        tag = Tag.by_id(tag_id)  # 获取标签
        articles = tag.articles  # 获取该标签的文章
    comments = Comment.all_createtime_desc()  # 获取所有评论
    tags, categorys = get_tags_categorys_lib(self)  # 获取标签和分类
    return articles, comments, categorys, tags  # 返回这些参数赋值给handler
コード例 #6
0
ファイル: article_libs.py プロジェクト: cyc41247293/OA-System
def add_second_comment_lib(self, content, comment_id):

    comment = Comment.by_id(comment_id)
    if comment is None:
        return {'status': False, 'msg': '评论不存在'}

    second_comment = SecondComment()
    second_comment.content = content
    second_comment.comment_id = comment.id
    second_comment.user_id = self.current_user.id
    self.db.add(second_comment)
    self.db.commit()
    return {'status': True, 'msg': '二级评论成功'}
コード例 #7
0
def add_second_comment_lib(self, commont_id, content):
    """08文章二级评论添加"""
    if commont_id is None:
        return {'status': False, 'msg': '缺少评论ID'}
    comment = Comment.by_id(commont_id)
    if comment is None:
        return {'status': False, 'msg': '评论不存在'}
    secondComment = SecondComment()
    secondComment.content = content
    secondComment.comment_id = commont_id
    secondComment.user_id = self.current_user.id
    self.db.add(secondComment)
    self.db.commit()
    return {'status': True, 'msg': '二级评论提交成功'}
コード例 #8
0
ファイル: article_libs.py プロジェクト: tomsue/oasystem
def second_comment_content_lib(self, comment_content, first_comment_id):
    ''' 二级评论内容存储 '''
    if comment_content == '':
        return {'status': False, 'msg': '评价不能为看'}
    first_comment = Comment.by_id(first_comment_id)
    if first_comment is None:
        return {'status': False, 'msg': '评价的评论已不存在'}

    second_comment = SecondComment()
    second_comment.content = comment_content
    second_comment.comment_id = first_comment_id
    second_comment.user_id = self.current_user.id
    self.db.add(second_comment)
    self.db.commit()
    return {'status': True, 'msg': '附加评论成功'}
コード例 #9
0
def add_second_comment_lib(self, content, comment_id):
    '''二次评论'''
    if content == '':
        return {'status': False, 'msg': '请输入评论!'}

    comment = Comment.by_id(comment_id)
    if comment is None:
        return {'status': False, 'msg': '文档不存在!'}

    second_comment = SecondComment()
    second_comment.content = content
    second_comment.comment_id = comment.id
    second_comment.user_id = self.current_user.id
    self.db.add(second_comment)
    self.db.commit()
    return {'status': True, 'msg': '评论成功!'}
コード例 #10
0
ファイル: article_libs.py プロジェクト: cyc41247293/OA-System
def article_list_lib(self):
    articles = Article.all_createtime_desc()
    comments = Comment.all_createtime_desc()
    tags, categorys = get_tags_categorys_lib(self)

    return articles, comments, categorys, tags