示例#1
0
文件: user.py 项目: voidf/sher_oa3
def alloc_user():
    for i in g.data['roles']:
        if not g.user.restrict_permission(Role.get_by_id(i).permission):
            return falseReturn(msg='您无法赋予他人权限不小于自己的角色')
        if not g.user.restrict_functions(Role.get_by_id(i).allow_functions):
            return falseReturn(msg='您无法赋予他人权能不在自己范围内的角色')
    u = User.get_by_id(g.data['id'])
    u.change_role(g.data['roles'])
    return trueReturn()
示例#2
0
def rename_role():
    if g.user.restrict_permission(Role.get_by_id(g.data['id']).permission):
        if g.user.restrict_functions(
                Role.get_by_id(g.data['id']).allow_functions):
            Role.get_by_id(g.data['id']).rename(g.data['name'])
            return trueReturn()
        else:
            return falseReturn(msg='您无法为权能比自己多的角色更名')
    else:
        return falseReturn(msg='您无法为权限不小于自己的角色更名')
示例#3
0
def remove_role():
    if g.user.restrict_permission(Role.get_by_id(g.data['id']).permission):
        if g.user.restrict_functions(
                Role.get_by_id(g.data['id']).allow_functions):
            Role.get_by_id(g.data['id']).delete()
            return trueReturn()
        else:
            return falseReturn(msg='您无法删除权能比自己多的角色')
    else:
        return falseReturn(msg='您无法删除权限不小于自己的角色')
示例#4
0
def edit_role():
    if g.user.restrict_permission(g.data['permission']):
        if g.user.restrict_functions(g.data['functions']):
            Role.get_by_id(g.data['id']).modify_permission(
                g.data['permission'])
            Role.get_by_id(g.data['id']).modify_functions(g.data['functions'])
            return trueReturn()
        else:
            return falseReturn(msg='您无法为角色分配自己没有的权能')
    else:
        return falseReturn(msg='您无法为角色分配不小于自身的权限')
示例#5
0
文件: User.py 项目: voidf/sher_oa3
 def change_role(self, roles):
     for p, i in enumerate(roles):
         if not isinstance(i, Role):
             roles[p] = Role.get_by_id(i)
     self.roles = roles
     return self.save()
示例#6
0
文件: role.py 项目: voidf/sher_oa3
def edit_role():
    Role.get_by_id(g.data['id']).modify_permission(g.data['permission'])
    Role.get_by_id(g.data['id']).modify_functions(g.data['functions'])
    return trueReturn()
示例#7
0
文件: role.py 项目: voidf/sher_oa3
def rename_role():
    Role.get_by_id(g.data['id']).rename(g.data['name'])
    return trueReturn()
示例#8
0
文件: role.py 项目: voidf/sher_oa3
def remove_role():
    Role.get_by_id(g.data['id']).delete()
    return trueReturn()