def add_role_lib(self, name):
    """02添加角色函数"""
    role= Role.by_name(name)
    if role is not None:
        flash(self, "角色已经存在,添加失败", "error")
        return
    role = Role()
    role.name = name
    self.db.add(role)
    self.db.commit()
    flash(self, "角色添加成功", "success")
Esempio n. 2
0
def save_role_name(self, role_name):
    ''' 存入新增角色名 '''
    if role_name == '':
        flash(self, "角色不能为空", "error")
        return
    role = Role.by_name(role_name)
    if role is not None:
        flash(self, "角色已经存在", "error")
        return

    role = Role()
    role.name = role_name
    self.db.add(role)
    self.db.commit()
    flash(self, "角色添加成功", "success")
def add_role_lib(self, name):
    '''02添加一个角色'''
    if not name:
        flash(self, '请输入角色名称!', 'error')
        return
    print type(name), 'name:%s' % name
    role = Role.by_name(name)
    if role is not None:
        flash(self, '角色已经存在!', 'error')
        return
    role = Role()
    role.name = name
    self.db.add(role)
    self.db.commit()
    flash(self, '角色添加成功!', 'success')