Exemple #1
0
    def post(self):
        ps = self.get_page_config(title='用户查询')

        user = self.get_args([
            'id', 'realName', 'name', 'tel', 'mobile', 'email',
            'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin',
            'lastUpdateTimeEnd'
        ], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        ps['page'] = int(self.get_arg('page', '1'))
        ps['pagedata'] = user_logic.query_page(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'],
            page=ps['page'],
            size=ps['size'])
        if None == ps['pagedata']:
            self.out_fail(code=101)
        else:
            self.out_ok(data=ps['pagedata'])
Exemple #2
0
 def get(self):
     users = user_logic.query_page()
     # users.append({'user_key': self.session.get('user_key')})
     print("*********", users)
     user = str_helper.json_encode(users)
     print("++++++++", user)
     self.write(user)
    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['userName'] = self.get_arg('userName', '')
        ps['userID'] = int(self.get_arg('userID', '0'))
        ps['userInfo'] = ''
        if ps['userID'] > 0:
            userInfo = user_logic.query_one(id = ps['userID'])
            ps['userInfo'] = userInfo['name']        

        ps['pagedata'] = user_logic.query_page(name = ps['userName'], 
            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/user_bind.html', **ps)
Exemple #4
0
 def post(self):
     ps = self.get_page_config(title = '用户查询')
     
     user = self.get_args(['id', 'realName', 'name', 'tel', 'mobile', 'email', 'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin', 'lastUpdateTimeEnd'], '')
     user['status'] = int(self.get_arg('status', '0'))
     user['departmentID'] = int(self.get_arg('departmentID', '0'))        
     ps['page'] = int(self.get_arg('page', '1'))        
     ps['pagedata'] = user_logic.query_page(id = user['id'],
                 name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                  tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                  status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'], page = ps['page'], size = ps['size'])
     if None == ps['pagedata']:
         self.out_fail(code = 101)
     else:
         self.out_ok(data = ps['pagedata'])
Exemple #5
0
 def get(self):
     ps = self.get_page_config(title = '用户列表')
     
     ps['ExportType'] = self.check_oper_right_custom_right(self._rightKey, self._exportUserKey)
     ps['LockType'] = self.check_oper_right_custom_right(self._rightKey, self._lockUserKey)
     user = self.get_args(['id', 'realName', 'name', 'tel', 'mobile', 'email', 'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin', 'lastUpdateTimeEnd'], '')
     user['status'] = int(self.get_arg('status', '0'))
     user['departmentID'] = int(self.get_arg('departmentID', '0'))
     ps['deps'] = department_logic.query_all_by_active()
     ps['page'] = int(self.get_arg('page', '1'))
     ps['userStatus'] = state.UserStatus
     ps['pagedata'] = user_logic.query_page(id = user['id'],
                 name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                  tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                  status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'], page = ps['page'], size = ps['size'])
     ps['user'] = user
     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/list.html', **ps)
Exemple #6
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')
        user = self.get_args(['id', 'realName', 'name', 'tel', 'mobile', 'email', 'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin', 'lastUpdateTimeEnd'], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        ps['deps'] = department_logic.query_all_by_active()
        ps['page'] = int(self.get_arg('page', '1'))
        ps['userStatus'] = state.UserStatus
        ps['pagedata'] = user_logic.query_page(id = user['id'],
                    name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                     tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                     status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'], page = ps['page'], size = 9999)

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

        #生成excel文件
        info = u'''<table><tr><td>用户ID</td><td>用户名</td><td>姓名</td><td>部门</td><td>状态</td>
                    <td>最后登录时间</td><td>创建人</td><td>创建时间</td><td>最后更新人</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><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>''' % (str(user['id']), user['name'], user['realName'], 
                        user['departmentName'], user['statusname'], user['lastLoginTime'], user['creater'], str(user['createTime'])[0:-3], 
                        user['lastUpdater'], str(user['lastUpdateTime'])[0:-3] )
            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)
Exemple #7
0
    def get(self):
        ps = self.get_page_config(title='用户列表')

        ps['ExportType'] = self.check_oper_right_custom_right(
            self._rightKey, self._exportUserKey)
        ps['LockType'] = self.check_oper_right_custom_right(
            self._rightKey, self._lockUserKey)
        user = self.get_args([
            'id', 'realName', 'name', 'tel', 'mobile', 'email',
            'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin',
            'lastUpdateTimeEnd'
        ], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        ps['deps'] = department_logic.query_all_by_active()
        ps['page'] = int(self.get_arg('page', '1'))
        ps['userStatus'] = state.UserStatus
        ps['pagedata'] = user_logic.query_page(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'],
            page=ps['page'],
            size=ps['size'])
        ps['user'] = user
        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/user/list_bs.html', **ps)
def _get_user_info(page, size):
	userPage = user_logic.query_page(id = '', name = '', realName = '', departmentID = 0, 
                        tel = '', mobile = '', email = '', status = state.statusUserActive, page = page, size = size)
	return userPage
Exemple #9
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')
        user = self.get_args(['id', 'realName', 'name', 'tel', 'mobile', 'email', 'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin', 'lastUpdateTimeEnd'], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        ps['deps'] = department_logic.query_all_by_active()
        ps['page'] = int(self.get_arg('page', '1'))
        ps['userStatus'] = state.UserStatus
        ps['pagedata'] = user_logic.query_page(id = user['id'],
                    name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                     tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                     status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'], page = ps['page'], size = 999999)

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

        userGroups = usergroup_logic.query_user_user_group(id = user['id'],
                    name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                     tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                     status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'])

        userGroupRoles = role_logic.query_user_user_group_role(id = user['id'],
                    name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                     tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                     status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'])

        userRoles =  role_logic.query_user_role(id = user['id'],
                    name = user['name'], realName = user['realName'], departmentID = user['departmentID'],
                     tel = user['tel'], mobile = user['mobile'], email = user['email'], 
                     status = user['status'], createTimeBegin = user['createTimeBegin'], createTimeEnd = user['createTimeEnd'], lastUpdateTimeBegin = user['lastUpdateTimeBegin'], lastUpdateTimeEnd = user['lastUpdateTimeEnd'])

        userGroupMap = {}
        rolesMap = {}

        for user in users:
            uid = str(user['id'])
            ug = []
            ugids = []
            #检索用户的所属用户组
            for userGroup in userGroups:
                if uid == str(userGroup['userID']):
                    ug.append(userGroup['userGroupName'])
                    ugids.append(str(userGroup['userGroupID']))
            userGroupMap[str(uid)] = ','.join(ug)

            ur = []
            for userRole in userRoles:
                if uid == str(userRole['userID']):
                    ur.append(userRole['roleName'])

            for ugid in ugids:
                for userGroupRole in userGroupRoles:
                    if ugid == str(userGroupRole['userGroupID']):
                        if userGroupRole['roleName'] not in ur:
                            ur.append(userGroupRole['roleName'])
            rolesMap[uid] = ','.join(ur)

        #生成excel文件
        info = u'''<table><tr><td>用户ID</td><td>用户名</td><td>姓名</td><td>部门</td><td>状态</td><td>锁定时间</td>
                    <td>最后登录时间</td><td>创建人</td><td>创建时间</td><td>最后更新人</td><td>最后更新时间</td><td>绑定用户组</td><td>绑定角色</td></tr>'''

        for user in users:
            uid = str(user['id'])
            u = u'''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>
                    <td>%s</td><td>%s</td><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'], user['statusname'], str(user['lockTime'])[0:-3], user['lastLoginTime'], user['creater'], str(user['createTime'])[0:-3], 
                        user['lastUpdater'], str(user['lastUpdateTime'])[0:-3], userGroupMap.get(uid,''), rolesMap.get(uid,''))
            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)
def _get_user_info(page, size):
	userPage = user_logic.query_page(id = '', name = '', realName = '', departmentID = 0, 
                        tel = '', mobile = '', email = '', status = state.statusUserActive, page = page, size = size)
	return userPage
Exemple #11
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')
        user = self.get_args([
            'id', 'realName', 'name', 'tel', 'mobile', 'email',
            'createTimeBegin', 'createTimeEnd', 'lastUpdateTimeBegin',
            'lastUpdateTimeEnd'
        ], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        ps['deps'] = department_logic.query_all_by_active()
        ps['page'] = int(self.get_arg('page', '1'))
        ps['userStatus'] = state.UserStatus
        ps['pagedata'] = user_logic.query_page(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'],
            page=ps['page'],
            size=999999)

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

        userGroups = usergroup_logic.query_user_user_group(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'])

        userGroupRoles = role_logic.query_user_user_group_role(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'])

        userRoles = role_logic.query_user_role(
            id=user['id'],
            name=user['name'],
            realName=user['realName'],
            departmentID=user['departmentID'],
            tel=user['tel'],
            mobile=user['mobile'],
            email=user['email'],
            status=user['status'],
            createTimeBegin=user['createTimeBegin'],
            createTimeEnd=user['createTimeEnd'],
            lastUpdateTimeBegin=user['lastUpdateTimeBegin'],
            lastUpdateTimeEnd=user['lastUpdateTimeEnd'])

        userGroupMap = {}
        rolesMap = {}

        for user in users:
            uid = str(user['id'])
            ug = []
            ugids = []
            #检索用户的所属用户组
            for userGroup in userGroups:
                if uid == str(userGroup['userID']):
                    ug.append(userGroup['userGroupName'])
                    ugids.append(str(userGroup['userGroupID']))
            userGroupMap[str(uid)] = ','.join(ug)

            ur = []
            for userRole in userRoles:
                if uid == str(userRole['userID']):
                    ur.append(userRole['roleName'])

            for ugid in ugids:
                for userGroupRole in userGroupRoles:
                    if ugid == str(userGroupRole['userGroupID']):
                        if userGroupRole['roleName'] not in ur:
                            ur.append(userGroupRole['roleName'])
            rolesMap[uid] = ','.join(ur)

        #生成excel文件
        info = u'''<table><tr><td>用户ID</td><td>用户名</td><td>姓名</td><td>部门</td><td>状态</td><td>锁定时间</td>
                    <td>最后登录时间</td><td>创建人</td><td>创建时间</td><td>最后更新人</td><td>最后更新时间</td><td>绑定用户组</td><td>绑定角色</td></tr>'''

        for user in users:
            uid = str(user['id'])
            u = u'''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>
                    <td>%s</td><td>%s</td><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'], user['statusname'],
                str(user['lockTime'])[0:-3], user['lastLoginTime'],
                user['creater'], str(user['createTime'])[0:-3],
                user['lastUpdater'], str(user['lastUpdateTime'])[0:-3],
                userGroupMap.get(uid, ''), rolesMap.get(uid, ''))
            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)