コード例 #1
0
def add_category_lib(self, name):
    category = Category.by_name(name)
    if category is not None:
        return {'status': False, 'msg': '该分类名已存在'}

    category = Category()
    category.name = name
    self.db.add(category)
    self.db.commit()
    return {'status': True, 'msg': '分类添加成功'}
コード例 #2
0
ファイル: article_libs.py プロジェクト: tomsue/oasystem
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}
コード例 #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': '请输入标签或分类'}
コード例 #4
0
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': '请添加分类或标签!'}
コード例 #5
0
def get_categoryid_lib(self):
    try:
        data = Category.by_name('计算机网络')
        return data.id
    except Exception as e:
        return