Esempio n. 1
0
    def post(self):
        self.check_oper_right(right = state.operEdit)
        ps = self.get_page_config(title = '编辑角色权限')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['appCode'] = self.get_arg('appCode', '')
        funcs = func_logic.query_all_by_app(ps['appCode'])     #获得应用下的所有功能

        funcs = role_logic.init_func_right(funcs)
        rights = []

        for func in funcs:      #收集权限数据
            map = {}
            map['funcID'] = func['id']
            r = int(self.get_arg(('right_%d_1' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_2' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_4' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_8' % func['id']), '0'))
            func['right'] = r
            map['right'] = r
            customRight = ''
            if func['customJson'] != None:                
                for c in func['customJson']:
                    cid = self.get_arg(('rightcustom_%d_%s' % (func['id'], c['k'])), '')
                    if cid != '':
                        customRight = customRight + cid + ','
                        c['right'] = True
                    else:
                        c['right'] = False
                if customRight != '':
                    customRight = ',' + customRight
            
            map['customRight'] = customRight
            rights.append(map)

        #保存权限信息
        type = role_logic.add_right_by_role_app(appCode = ps['appCode'], 
            roleID = ps['roleID'], rights = rights, user = self.get_oper_user())
        
        roles = role_logic.query_all_by_active()
        apps = application_logic.query_all_by_active()
        ps['apps'] = apps
        ps['roles'] = roles
        ps = self.format_none_to_empty(ps)
        ps['funcs'] = funcs

        if type:
            self.write_oper_log(action = 'roleSetRight', targetType = 5, targetID = str(ps['roleID']), targetName = ps['appCode'], startStatus = '', endStatus= str_helper.json_encode(rights))
            ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
        else:
            ps['msg'] = state.ResultInfo.get(104004, '')
        self.render('admin/role/right_edit.html', **ps)
Esempio n. 2
0
    def post(self):
        self.check_oper_right(right = state.operEdit)
        ps = self.get_page_config(title = '编辑角色权限')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['appCode'] = self.get_arg('appCode', '')
        funcs = func_logic.query_all_by_app(ps['appCode'])     #获得应用下的所有功能

        funcs = role_logic.init_func_right(funcs)
        rights = []

        for func in funcs:      #收集权限数据
            map = {}
            map['funcID'] = func['id']
            r = int(self.get_arg(('right_%d_1' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_2' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_4' % func['id']), '0'))
            r = r + int(self.get_arg(('right_%d_8' % func['id']), '0'))
            func['right'] = r
            map['right'] = r
            customRight = ''
            if func['customJson'] != None:                
                for c in func['customJson']:
                    cid = self.get_arg(('rightcustom_%d_%s' % (func['id'], c['k'])), '')
                    if cid != '':
                        customRight = customRight + cid + ','
                        c['right'] = True
                    else:
                        c['right'] = False
                if customRight != '':
                    customRight = ',' + customRight
            
            map['customRight'] = customRight
            rights.append(map)

        #保存权限信息
        type = role_logic.add_right_by_role_app(appCode = ps['appCode'], 
            roleID = ps['roleID'], rights = rights, user = self.get_oper_user())
        
        roles = role_logic.query_all_by_active()
        apps = application_logic.query_all_by_active()
        ps['apps'] = apps
        ps['roles'] = roles
        ps = self.format_none_to_empty(ps)
        ps['funcs'] = funcs

        if type:
            self.write_oper_log(action = 'roleSetRight', targetType = 5, targetID = str(ps['roleID']), targetName = ps['appCode'], startStatus = '', endStatus= str_helper.json_encode(rights))
            ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
        else:
            ps['msg'] = state.ResultInfo.get(104004, '')
        self.render('admin/role/right_edit_bs.html', **ps)
Esempio n. 3
0
    def get(self):
        ps = self.get_page_config(title = '编辑角色权限', refUrl = config.SOCRightConfig['siteDomain'] + 'Admin/Role/List')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['appCode'] = self.get_arg('appCode', '')
        ps['roles'] = []
        ps['apps'] = []
        roles = role_logic.query_all_by_active()
        if None == roles or len(roles) == 0:
            ps['msg'] = state.ResultInfo.get(104003, '')
            ps['refUrl'] = ps['siteDomain'] +'Admin/Role/Add'
            self.render('admin/role/right_edit.html', **ps)
            return
        else:
            if 0 == ps['roleID']:
                ps['roleID'] = roles[0]['id']    
        apps = application_logic.query_all_by_active()
        if None == apps or len(apps) == 0:
            ps['msg'] = state.ResultInfo.get(104003, '')
            ps['refUrl'] = ps['siteDomain'] +'Admin/Application/Add'
            self.render('admin/role/right_edit.html', **ps)
            return
        else:
            if '' == ps['appCode']:
                ps['appCode'] = apps[0]['code']
        ps['apps'] = apps
        ps['roles'] = roles
        ps = self.format_none_to_empty(ps)

        funcs = func_logic.query_all_by_app(ps['appCode'])     #获得应用下的所有功能
        if None != funcs and len(funcs) > 0:
            funcs = role_logic.init_func_right(funcs)
            funcs = role_logic.format_role_func_right(appCode = ps['appCode'], roleID = ps['roleID'], funcs = funcs)
        else:
            funcs = []
        ps['funcs'] = funcs
        if self.is_edit():
            self.check_oper_right(right = state.operEdit)
            self.render('admin/role/right_edit.html', **ps)
        else:
            self.check_oper_right(right = state.operView)
            self.render('admin/role/right_detail.html', **ps)
Esempio n. 4
0
    def get(self):
        ps = self.get_page_config(title = '编辑角色权限', refUrl = config.SOCRightConfig['siteDomain'] + 'Admin/Role/List')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['appCode'] = self.get_arg('appCode', '')
        ps['roles'] = []
        ps['apps'] = []
        roles = role_logic.query_all_by_active()
        if None == roles or len(roles) == 0:
            ps['msg'] = state.ResultInfo.get(104003, '')
            ps['refUrl'] = ps['siteDomain'] +'Admin/Role/Add'
            self.render('admin/role/right_edit_bs.html', **ps)
            return
        else:
            if 0 == ps['roleID']:
                ps['roleID'] = roles[0]['id']    
        apps = application_logic.query_all_by_active()
        if None == apps or len(apps) == 0:
            ps['msg'] = state.ResultInfo.get(104003, '')
            ps['refUrl'] = ps['siteDomain'] +'Admin/Application/Add'
            self.render('admin/role/right_edit_bs.html', **ps)
            return
        else:
            if '' == ps['appCode']:
                ps['appCode'] = apps[0]['code']
        ps['apps'] = apps
        ps['roles'] = roles
        ps = self.format_none_to_empty(ps)

        funcs = func_logic.query_all_by_app(ps['appCode'])     #获得应用下的所有功能
        if None != funcs and len(funcs) > 0:
            funcs = role_logic.init_func_right(funcs)
            funcs = role_logic.format_role_func_right(appCode = ps['appCode'], roleID = ps['roleID'], funcs = funcs)
        else:
            funcs = []
        ps['funcs'] = funcs
        if self.is_edit():
            self.check_oper_right(right = state.operEdit)
            self.render('admin/role/right_edit_bs.html', **ps)
        else:
            self.check_oper_right(right = state.operView)
            self.render('admin/role/right_detail_bs.html', **ps)