def add_permission_lib(self, name, strcode):
    """04添加权限"""
    permission = Permission.by_name(name)
    if permission is not None:
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
def add_permission_lib(self, name, strcode):
    """04添加权限"""
    permission= Permission.by_name(name)
    if permission is not None:
        flash(self, "权限已存在,添加失败", "error")
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
    flash(self, "权限添加成功", "success")
Example #3
0
def permission_add_code(self, permission_name, permission_code):
    ''' 添加权限名和权限码 '''
    if permission_name == '':
        return {'status': False, 'msg': '请输入权限名'}
    if permission_code == '':
        return {'status': False, 'msg': '请输入权限码'}
    permission = Permission()
    permission.name = permission_name
    permission.strcode = permission_code
    self.db.add(permission)
    self.db.commit()
    return {'status': True, 'msg': '添加成功'}
def add_permission_lib(self, name, strcode):
    '''04添加权限'''
    if not name or not strcode:
        flash(self, '请输入权限名和权限码!', 'error')
        return
    permission = Permission.by_name(name)
    # 如果权限有,就不用添加
    if permission is not None:
        flash(self, '权限已存在!', 'error')
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
    flash(self, '权限添加成功!', 'success')