Ejemplo n.º 1
0
def delete_category_lib(self, id):
    categorys = Category.by_id(id)
    tags = Tag.all()
    if categorys is None:
        return Category.all(), tags

    self.db.delete(categorys)
    self.db.commit()
    return Category.all(), tags
Ejemplo n.º 2
0
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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def search_article_lib(self, category_id, tag_id):
    if tag_id is not None:
        tag = Tag.by_id(tag_id)
        articles = tag.articles
    if category_id is not None:
        category = Category.by_id(category_id)
        articles = category.articles
    comments = dbSession.query(Comment).order_by(
        Comment.createtime.desc()).all()
    tags = Tag.all()
    categorys = Category.all()
    return articles, comments, tags, categorys