Пример #1
0
    def get(self):
        ps = self.get_page_config(title = '新增角色绑定用户')
        ps['userID'] = int(self.get_arg('userID', '0'))
        if 0 == ps['userID']:
            ps['msg'] = state.ResultInfo.get(103003, '')
            ps['gotoUrl'] = ps['siteDomain'] +'Admin/User/Add'
            self.render('admin/user/role_list.html', **ps)
            return

        ps['page'] = int(self.get_arg('page', '1'))        
        ps['roleName'] = self.get_arg('roleName', '')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['roleInfo'] = ''
        if ps['roleID'] > 0:
            roleInfo = role_logic.query_one(id = ps['roleID'])
            ps['roleInfo'] = roleInfo['name']        

        ps['pagedata'] = role_logic.query_page(name = ps['roleName'], 
            status = state.statusActive, page = ps['page'], size = ps['size'])
        
        user = user_logic.query_one(id = ps['userID'])
        ps['userInfo'] = user['name']
        ps['userRealName'] = user['realName']

        ps = self.format_none_to_empty(ps)
        ps['pager'] = self.build_page_html(page = ps['page'], size = ps['size'], total = ps['pagedata']['total'], pageTotal = ps['pagedata']['pagetotal'])        
        self.render('admin/user/role_bind.html', **ps)
Пример #2
0
    def get(self):
        # type = self.check_oper_right_custom_right(self._rightKey, self._exportUserKey)
        # if type == False:
        #     self.redirect(config.SOCRightConfig['siteDomain']+'Admin/NotRight')
        #     return

        import sys
        reload(sys)                        
        sys.setdefaultencoding('utf-8')    
        ps = self.get_page_config(title = '导出角色用户列表Excel')

        role = {}
        role['id'] = int(self.get_arg('id', '0'))
        role = role_logic.query_one(id = role['id'])
        ps['userName'] = self.get_arg('userName', '')        
        ps['page'] = int(self.get_arg('page', '1'))
        ps['pagedata'] = user_logic.query_page_by_roleid(roleID = role['id'], userName = ps['userName'], page = 1, size = 99999)

        users = ps['pagedata']['data']

        #生成excel文件
        info = u'''<table><tr><td>用户ID</td><td>用户名</td><td>姓名</td><td>部门名称</td><td>角色ID</td><td>角色名</td></tr>'''

        for user in users:
            u = u'''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>''' % (str(user['id']), user['name'], user['realName'], 
                        user['departmentName'], role['id'], role['name'] )
            info = info + u
        info = info + u'</table>'
        fileName = config.SOCRightConfig['exportUserPath'] + str_helper.get_now_datestr() +'_'+ str_helper.get_uuid() + '.xls'

        path = config.SOCRightConfig['realPath'] + fileName
        file_object = open(path, 'w')
        file_object.write(info)
        file_object.close( )    
        self.redirect(config.SOCRightConfig['siteDomain']+fileName)
Пример #3
0
    def get(self):
        # type = self.check_oper_right_custom_right(self._rightKey, self._exportUserKey)
        # if type == False:
        #     self.redirect(config.SOCRightConfig['siteDomain']+'Admin/NotRight')
        #     return

        import sys
        reload(sys)                        
        sys.setdefaultencoding('utf-8')    
        ps = self.get_page_config(title = '导出角色用户列表Excel')

        role = {}
        role['id'] = int(self.get_arg('id', '0'))
        role = role_logic.query_one(id = role['id'])
        ps['userName'] = self.get_arg('userName', '')        
        ps['page'] = int(self.get_arg('page', '1'))
        ps['pagedata'] = user_logic.query_page_by_roleid(roleID = role['id'], userName = ps['userName'], page = 1, size = 99999)

        users = ps['pagedata']['data']

        #生成excel文件
        info = u'''<table><tr><td>用户ID</td><td>用户名</td><td>姓名</td><td>部门名称</td><td>角色ID</td><td>角色名</td></tr>'''

        for user in users:
            u = u'''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>''' % (str(user['id']), user['name'], user['realName'], 
                        user['departmentName'], role['id'], role['name'] )
            info = info + u
        info = info + u'</table>'
        fileName = config.SOCRightConfig['exportUserPath'] + str_helper.get_now_datestr() +'_'+ str_helper.get_uuid() + '.xls'

        path = config.SOCRightConfig['realPath'] + fileName
        file_object = open(path, 'w')
        file_object.write(info)
        file_object.close( )    
        self.redirect(config.SOCRightConfig['siteDomain']+fileName)
Пример #4
0
    def get(self):
        ps = self.get_page_config(title = '新增角色绑定用户组')
        ps['userGroupID'] = int(self.get_arg('userGroupID', '0'))
        userGroups = usergroup_logic.query_all_by_active()
        if None == userGroups or len(userGroups) == 0:
            ps['msg'] = state.ResultInfo.get(105003, '')
            ps['gotoUrl'] = ps['siteDomain'] +'Admin/UserGroup/Add'
            self.render('admin/usergroup/user_bind.html', **ps)
            return
        else:
            if 0 == ps['userGroupID']:
                ps['userGroupID'] = userGroups[0]['id']

        ps['userGroups'] = userGroups
        ps['page'] = int(self.get_arg('page', '1'))        
        ps['roleName'] = self.get_arg('roleName', '')
        ps['roleID'] = int(self.get_arg('roleID', '0'))
        ps['roleInfo'] = ''
        if ps['roleID'] > 0:
            roleInfo = role_logic.query_one(id = ps['roleID'])
            ps['roleInfo'] = roleInfo['name']        

        ps['pagedata'] = role_logic.query_page(name = ps['roleName'], 
            status = state.statusActive, page = ps['page'], size = ps['size'])
        ps = self.format_none_to_empty(ps)
        ps['pager'] = self.build_page_html(page = ps['page'], size = ps['size'], total = ps['pagedata']['total'], pageTotal = ps['pagedata']['pagetotal'])        
        self.render('admin/usergroup/role_bind.html', **ps)
Пример #5
0
    def post(self):
        ps = self.get_page_config(title = '创建角色')
        if ps['isedit']:
            ps['title'] = self.get_page_title('编辑角色')

        role = self.get_args(['id', 'name', 'remark'], '')
        role['status'] = int(self.get_arg('status', '0'))
        ps['role'] = role
        msg = self.check_str_empty_input(role, ['name'])
        if str_helper.is_null_or_empty(msg) == False:
            ps['msg'] = msg
            ps = self.format_none_to_empty(ps)
            self.render('admin/role/add_or_edit.html', **ps)
            return
        role['user'] = self.get_oper_user()
        
        if ps['isedit']:
            self.check_oper_right(right = state.operEdit)
            try:
                oro = role_logic.query_one(role['id'])
                info = role_logic.update(id = role['id'], name = role['name'], 
                        status = role['status'], remark = role['remark'], user = role['user'])                
                if info:                    
                    nro = role_logic.query_one(role['id'])
                    self.write_oper_log(action = 'roleEdit', targetType = 5, targetID = str(nro['id']), targetName = nro['name'], startStatus = str_helper.json_encode(oro), endStatus= str_helper.json_encode(nro))
                    ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
                else:
                    ps['msg'] = state.ResultInfo.get(101, '')
            except error.RightError as e:
                ps['msg'] = e.msg
        else:
            self.check_oper_right(right = state.operAdd)
            try:
                info = role_logic.add(name = role['name'], 
                        status = role['status'], remark = role['remark'], user = role['user'])
                if info > 0:
                    nro = role_logic.query_one_by_name(role['name'])
                    self.write_oper_log(action = 'roleEdit', targetType = 5, targetID = str(nro['id']), targetName = nro['name'], startStatus = '', endStatus= str_helper.json_encode(nro))
                    ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
                else:
                    ps['msg'] = state.ResultInfo.get(101, '')
            except error.RightError as e:
                ps['msg'] = e.msg
        ps = self.format_none_to_empty(ps)
        self.render('admin/role/add_or_edit.html', **ps)
Пример #6
0
    def post(self):
        ps = self.get_page_config(title = '创建角色')
        if ps['isedit']:
            ps['title'] = self.get_page_title('编辑角色')

        role = self.get_args(['id', 'name', 'remark'], '')
        role['status'] = int(self.get_arg('status', '0'))
        ps['role'] = role
        msg = self.check_str_empty_input(role, ['name'])
        if str_helper.is_null_or_empty(msg) == False:
            ps['msg'] = msg
            ps = self.format_none_to_empty(ps)
            self.render('admin/role/add_or_edit_bs.html', **ps)
            return
        role['user'] = self.get_oper_user()
        
        if ps['isedit']:
            self.check_oper_right(right = state.operEdit)
            try:
                oro = role_logic.query_one(role['id'])
                info = role_logic.update(id = role['id'], name = role['name'], 
                        status = role['status'], remark = role['remark'], user = role['user'])                
                if info:                    
                    nro = role_logic.query_one(role['id'])
                    self.write_oper_log(action = 'roleEdit', targetType = 5, targetID = str(nro['id']), targetName = nro['name'], startStatus = str_helper.json_encode(oro), endStatus= str_helper.json_encode(nro))
                    ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
                else:
                    ps['msg'] = state.ResultInfo.get(101, '')
            except error.RightError as e:
                ps['msg'] = e.msg
        else:
            self.check_oper_right(right = state.operAdd)
            try:
                info = role_logic.add(name = role['name'], 
                        status = role['status'], remark = role['remark'], user = role['user'])
                if info > 0:
                    nro = role_logic.query_one_by_name(role['name'])
                    self.write_oper_log(action = 'roleEdit', targetType = 5, targetID = str(nro['id']), targetName = nro['name'], startStatus = '', endStatus= str_helper.json_encode(nro))
                    ps = self.get_ok_and_back_params(ps = ps, refUrl = ps['refUrl'])
                else:
                    ps['msg'] = state.ResultInfo.get(101, '')
            except error.RightError as e:
                ps['msg'] = e.msg
        ps = self.format_none_to_empty(ps)
        self.render('admin/role/add_or_edit_bs.html', **ps)
Пример #7
0
 def post(self):
     id = int(self.get_arg('id', '0'))
     user = self.get_oper_user()
     oro = role_logic.query_one(id)
     type = role_logic.delete(id = id, user = user)
     if type:
         self.write_oper_log(action = 'roleDelete', targetType = 5, targetID = str(oro['id']), targetName = oro['name'], startStatus = str_helper.json_encode(oro), endStatus= '')
         self.out_ok()
     else:
         self.out_fail(code = 101)
Пример #8
0
 def post(self):
     id = int(self.get_arg('id', '0'))
     user = self.get_oper_user()
     oro = role_logic.query_one(id)
     type = role_logic.delete(id = id, user = user)
     if type:
         self.write_oper_log(action = 'roleDelete', targetType = 5, targetID = str(oro['id']), targetName = oro['name'], startStatus = str_helper.json_encode(oro), endStatus= '')
         self.out_ok()
     else:
         self.out_fail(code = 101)
Пример #9
0
 def get(self):
     ps = self.get_page_config(title = '角色详情')
     id = int(self.get_arg('id', '0'))
     role = role_logic.query_one(id)
     if None == role:
         ps['msg'] = state.ResultInfo.get(104002, '')
         ps['gotoUrl'] = ps['siteDomain'] +'Admin/Role/List'
         role = {'id':'','name':'', 'statusname':'','status':1, 'remark':'','creater':'','createTime':'','lastUpdater':'','lastUpdateTime':''}        
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     self.render('admin/role/detail_bs.html', **ps)
Пример #10
0
 def get(self):
     ps = self.get_page_config(title = '角色详情')
     id = int(self.get_arg('id', '0'))
     role = role_logic.query_one(id)
     if None == role:
         ps['msg'] = state.ResultInfo.get(104002, '')
         ps['gotoUrl'] = ps['siteDomain'] +'Admin/Role/List'
         role = {'id':'','name':'', 'statusname':'','status':1, 'remark':'','creater':'','createTime':'','lastUpdater':'','lastUpdateTime':''}        
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     self.render('admin/role/detail.html', **ps)
Пример #11
0
 def get(self):
     ps = self.get_page_config(title = '角色用户列表')
     ps['ExportType'] = True
     role = {}
     role['id'] = int(self.get_arg('id', '0'))
     role = role_logic.query_one(id = role['id'])
     ps['userName'] = self.get_arg('userName', '')        
     ps['page'] = int(self.get_arg('page', '1'))
     ps['pagedata'] = user_logic.query_page_by_roleid(roleID = role['id'], userName = ps['userName'], page = ps['page'], size = ps['size'])
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     ps['pager'] = self.build_page_html(page = ps['page'], size = ps['size'], total = ps['pagedata']['total'], pageTotal = ps['pagedata']['pagetotal'])        
     self.render('admin/role/user_list.html', **ps)
Пример #12
0
 def get(self):
     ps = self.get_page_config(title = '角色用户列表')
     ps['ExportType'] = True
     role = {}
     role['id'] = int(self.get_arg('id', '0'))
     role = role_logic.query_one(id = role['id'])
     ps['userName'] = self.get_arg('userName', '')        
     ps['page'] = int(self.get_arg('page', '1'))
     ps['pagedata'] = user_logic.query_page_by_roleid(roleID = role['id'], userName = ps['userName'], page = ps['page'], size = ps['size'])
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     ps['pager'] = self.build_page_html_bs(page = ps['page'], size = ps['size'], total = ps['pagedata']['total'], pageTotal = ps['pagedata']['pagetotal'])        
     self.render('admin/role/user_list_bs.html', **ps)
Пример #13
0
    def get(self):
        ps = self.get_page_config(title = '角色用户组列表')
        role = {}
        role['id'] = int(self.get_arg('id', '0'))
        print role['id']
        role = role_logic.query_one(id = role['id'])
        ps['role'] = role

        ps['page'] = int(self.get_arg('page', '1'))

        ps['pagedata'] = role_logic.query_page_role_groups(roleID = role['id'], page = ps['page'], size = ps['size'])
        ps = self.format_none_to_empty(ps)
        ps['pager'] = self.build_page_html_bs(page = ps['page'], size = ps['size'], total = ps['pagedata']['total'], pageTotal = ps['pagedata']['pagetotal'])        
        self.render('admin/role/user_group_list_bs.html', **ps)
Пример #14
0
    def post(self):
        userID = int(self.get_arg('userID', '0'))
        roleID = int(self.get_arg('roleID', '0'))
        if 0 == userID or 0 == roleID:
            self.out_fail(code = 1001)
            return

        user = self.get_oper_user()
        oro = role_logic.query_one(roleID)
        type = role_logic.delete_user_bind(userID = userID, roleID = roleID, user = user)
        if type:
            self.write_oper_log(action = 'roleUserDelete', targetType = 5, targetID = str(oro['id']), targetName = oro['name'], startStatus = str(userID), endStatus= '')
            self.out_ok()
        else:
            self.out_fail(code = 101)
Пример #15
0
    def post(self):
        userID = int(self.get_arg('userID', '0'))
        roleID = int(self.get_arg('roleID', '0'))
        if 0 == userID or 0 == roleID:
            self.out_fail(code = 1001)
            return

        user = self.get_oper_user()
        oro = role_logic.query_one(roleID)
        type = role_logic.delete_user_bind(userID = userID, roleID = roleID, user = user)
        if type:
            self.write_oper_log(action = 'roleUserDelete', targetType = 5, targetID = str(oro['id']), targetName = oro['name'], startStatus = str(userID), endStatus= '')
            self.out_ok()
        else:
            self.out_fail(code = 101)
Пример #16
0
 def get(self):
     ps = self.get_page_config(title = '创建角色', refUrl = config.SOCRightConfig['siteDomain'] + 'Admin/Role/List')
     if ps['isedit']:
         self.check_oper_right(right = state.operEdit)
         ps['title'] = self.get_page_title('编辑角色')
         id = int(self.get_arg('id', '0'))
         role = role_logic.query_one(id)
         if None == role:
             ps['msg'] = state.ResultInfo.get(104002, '')
             role = {'id':'','name':'','status':1,'remark':'','creater':'','createTime':'','lastUpdater':'','lastUpdateTime':''}
     else:
         self.check_oper_right(right = state.operAdd)
         role = self.get_args(['id', 'name', 'remark'], '')
         role['status'] = int(self.get_arg('status', '0'))
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     self.render('admin/role/add_or_edit.html', **ps)
Пример #17
0
 def get(self):
     ps = self.get_page_config(title = '创建角色', refUrl = config.SOCRightConfig['siteDomain'] + 'Admin/Role/List')
     if ps['isedit']:
         self.check_oper_right(right = state.operEdit)
         ps['title'] = self.get_page_title('编辑角色')
         id = int(self.get_arg('id', '0'))
         role = role_logic.query_one(id)
         if None == role:
             ps['msg'] = state.ResultInfo.get(104002, '')
             role = {'id':'','name':'','status':1,'remark':'','creater':'','createTime':'','lastUpdater':'','lastUpdateTime':''}
     else:
         self.check_oper_right(right = state.operAdd)
         role = self.get_args(['id', 'name', 'remark'], '')
         role['status'] = int(self.get_arg('status', '0'))
     ps['role'] = role
     ps = self.format_none_to_empty(ps)
     self.render('admin/role/add_or_edit_bs.html', **ps)