Example #1
0
def add_tag_lib(self, name):
    tag = Tag.by_name(name)
    if tag is not None:
        return {'status': False, 'msg': '该标签名已存在'}

    tag = Tag()
    tag.name = name
    self.db.add(tag)
    self.db.commit()
    return {'status': True, 'msg': '标签添加成功'}
Example #2
0
def add_category_tag_lib(self, category_name='', tag_name=''):
    ''' 添加文章的分类和标签 '''
    if category_name != '':
        category = Category.by_name(category_name)
        if category == None:
            category = Category()
            category.name = category_name
            self.db.add(category)
            self.db.commit()
    if tag_name != '':
        tag = Tag.by_name(tag_name)
        if tag == None:
            tag = Tag()
            tag.name = tag_name
            self.db.add(tag)
            self.db.commit()
    return {'status': True}
Example #3
0
def add_category_tag_lib(self, category_name, tag_name):
    """03添加分类和标签"""
    if category_name is not None:
        category = Category.by_name(category_name)
        if category is not None:
            return {'status': False, 'msg': '分类已经存在'}
        else:
            category = Category()
        category.name = category_name
        self.db.add(category)
        self.db.commit()
        return {'status': True, 'msg': '分类添加成功'}
    if tag_name is not None:
        tag = Tag.by_name(tag_name)
        if tag is not None:
            return {'status': False, 'msg': '标签已经存在'}
        else:
            tag = Tag()
        tag.name = tag_name
        self.db.add(tag)
        self.db.commit()
        return {'status': True, 'msg': '标签添加成功'}
    return {'status': False, 'msg': '请输入标签或分类'}
def add_tags_categorys_lib(self, category_name, tag_name):
    '''管理标签'''
    if category_name != '':
        category = Category.by_name(category_name)
        if category is not None:
            return {'status': False, 'msg': '该分类名已存在!'}
        else:
            category = Category()
        category.name = category_name
        self.db.add(category)
        self.db.commit()
        return {'status': True, 'msg': '分类添加成功!'}

    if tag_name != '':
        tag = Tag.by_name(tag_name)
        if tag is not None:
            return {'status': False, 'msg': '该分类名已存在!'}
        else:
            tag = Tag()
            tag.name = tag_name
        self.db.add(tag)
        self.db.commit()
        return {'status': True, 'msg': '分类添加成功!'}
    return {'status': False, 'msg': '请添加分类或标签!'}