示例#1
0
def del_category_tag_lib(self, c_uuid, t_uuid):
    """04删除标签和分类"""
    if c_uuid is not None:
        category = Category.by_uuid(c_uuid)
        if category is None:
            flash(self, '分类不存在', 'error')
            return {'status': False}
        if category.articles:
            flash(self, '分类下有文章请先删除文章', 'error')
            return {'status': False}
        self.db.delete(category)
        self.db.commit()
        flash(self, '分类删除成功', 'success')
        return {'status': True}
    if t_uuid is not None:
        tag = Tag.by_uuid(t_uuid)
        if tag is None:
            flash(self, '标签不存在', 'error')
            return {'status': False, 'msg': '标签不存在'}
        self.db.delete(tag)
        self.db.commit()
        flash(self, '标签删除成功', 'success')
        return {'status': True}
    flash(self, '请输入标签或分类', 'error')
    return {'status': False}
示例#2
0
def del_category_tag_lib(self, c_uuid, t_uuid):
    """05删除分类或者标签"""
    try:
        if c_uuid is not None:
            category = Category.by_uuid(c_uuid)
            if category is None:
                flash(self, '分类不存在', 'error')
                return {'status': False}
            if category.articles:
                flash(self, '分类下存在文章,清先删除文章再删除此分类', 'error')
                return {'status': False}
            self.db.delete(category)
            self.db.commit()
            flash(self, '分类删除成功', 'success')
            return {'status': True}
        if t_uuid is not None:
            tag = Tag.by_uuid(t_uuid)
            if tag:
                flash(self, '标签不存在', 'error')
            self.db.delete(tag)
            self.db.commit()
            flash(self, '标签删除成功', 'success')
            return {'status': True}
        flash(self, '标签或分类删除失败', 'error')
        return {'status': False}
    except Exception as e:
        flash(self, '标签或分类删除失败', 'error')
        return {'status': False}
示例#3
0
def del_category_tag_lib(self, category_uuid, tag_uuid):
    ''' 删除分类,标签 '''
    category = Category.by_uuid(category_uuid)
    tag = Tag.by_uuid(tag_uuid)
    if category != None:
        self.db.delete(category)
    if tag != None:
        self.db.delete(tag)
    self.db.commit()
    return {'status': True}
def delete_tags_categorys_lib(self, c_uuid, t_uuid):
    '''删除分类和标签'''
    category = Category.by_uuid(c_uuid)
    tag = Tag.by_uuid(t_uuid)

    if category is None and tag is None:
        tags, categorys = get_tags_categorys_lib(self)
        return tags, categorys
    if category is not None:
        self.db.delete(category)
        self.db.commit()

    print 'tag:%s' % tag

    if tag is not None:
        self.db.delete(tag)
        self.db.commit()
    print 'test.....'
    tags, categorys = get_tags_categorys_lib(self)
    return tags, categorys