Exemplo n.º 1
0
    def post(self):
        params = self.get_args(['name', 'path', 'customJson', 'rights', 'remark', 'user'], '')
        params['sort'] = int(self.get_arg('sort', '0'))
        params['status'] = int(self.get_arg('status', '0'))

        msg = self.check_str_empty_input(params, ['name', 'path', 'user'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return

        func = func_logic.query_one_by_path(path = params['path'])
        if None == func:
            self.out_fail(code = 102004)
            return

        user = user_logic.query_one_by_name(params['user'])
        if None == user:
            self.out_fail(code = 103002)

        print self.get_argument('rights')
        try:
            result = func_logic.update(id = func['id'], name = params['name'], sort = params['sort'], rights = params['rights'], 
                customJson = params['customJson'], remark = params['remark'], user = params['user'])

            if True == result:
                self.write_oper_log(action = 'funcEditInterface', targetType = 3, targetID = str(func['id']), 
                    targetName = params['name'], startStatus = '', endStatus= str_helper.json_encode(params), user = user)
                self.out_ok()
            else:
                self.out_fail(code = 101)            
        except error.RightError as e:
            self.out_fail(code=e.code)
            return
        return
        
Exemplo n.º 2
0
    def post(self):
        # ps = self.get_page_config(title = '重置用户密码')
        name = self.get_arg('name', '')

        type = self.check_oper_right_custom_right(self._rightKey,
                                                  self._resetPwKey)
        if type == False:
            self.out_fail(code=1004)
            self.finish()
            return
        # userName = self.get_arg('userName', '')
        if None == name or '' == name:
            self.out_fail(code=103007)
            return

        newPW = user_logic.reset_password(name)
        if None == newPW or '' == newPW:
            self.out_fail(code=101)
            return

        ou = user_logic.query_one_by_name(name=name)
        self.write_oper_log(action='userResetPw',
                            targetType=1,
                            targetID=str(ou['id']),
                            targetName=name,
                            startStatus='',
                            endStatus='')
        self.out_ok(data='{"newpw":"' + newPW + '"}')
Exemplo n.º 3
0
    def post(self):
        params = self.get_args(['appCode', 'name', 'code', 'parentPath', 'customJson', 'rights', 'remark', 'user'], '')
        params['sort'] = int(self.get_arg('sort', '0'))
        params['status'] = int(self.get_arg('status', '0'))

        msg = self.check_str_empty_input(params, ['appCode', 'name', 'code', 'parentPath', 'user'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return

        btype = str_helper.check_num_abc__(params['code'])
        if btype == False:
            self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线')
            return

        parent = func_logic.query_one_by_path(path = params['parentPath'])
        if None == parent:
            self.out_fail(code = 102004)
            return

        path = parent['path']+'.'+params['code']
        func = func_logic.query_one_by_path(path = path)
        if None != func:
            self.out_fail(code = 102003)
            return

        user = user_logic.query_one_by_name(params['user'])
        if None == user:
            self.out_fail(code = 103002)

        try:
            result = func_logic.add(appCode = params['appCode'], name = params['name'], 
                code = params['code'], parentID = parent['id'], path = path, rights = params['rights'],
                customJson = params['customJson'], sort = params['sort'], 
                status = params['status'], remark = params['remark'], user = params['user'])

            self.out_ok()
            
            self.write_oper_log(action = 'funcCreateInterface', targetType = 3, targetID = str(result), targetName = params['name'], startStatus = '', endStatus= str_helper.json_encode(params), user = user)
        except error.RightError as e:
            self.out_fail(code=e.code)
            return
        return
Exemplo n.º 4
0
    def post(self):
        # ps = self.get_page_config(title = '重置用户密码')
        name = self.get_arg('name', '')

        type = self.check_oper_right_custom_right(self._rightKey, self._resetPwKey)
        if type == False:
            self.out_fail(code = 1004)
            self.finish()
            return
        # userName = self.get_arg('userName', '')
        if None == name or '' == name:
            self.out_fail(code = 103007)
            return
        
        newPW = user_logic.reset_password(name)
        if None == newPW or '' == newPW:
            self.out_fail(code = 101)
            return

        ou = user_logic.query_one_by_name(name = name)
        self.write_oper_log(action = 'userResetPw', targetType = 1, targetID = str(ou['id']), targetName = name, startStatus = '', endStatus= '')
        self.out_ok(data = '{"newpw":"'+newPW+'"}')
Exemplo n.º 5
0
    def post(self):
        ps = self.get_page_config(title = '创建用户')
        ps['ResetPasswordType'] = self.check_oper_right_custom_right(self._rightKey, self._resetPwKey)
        if ps['isedit']:
            ps['title'] = self.get_page_title('编辑用户')

        user = self.get_args(['id', 'passWord', 'name', 'realName', 'mobile', 'tel', 'email', 'remark', 'beginDate', 'endDate'], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        user['parentID'] = int(self.get_arg('parentID', '0'))
        ps['user'] = user
        ps['userStatus'] = state.UserStatus
        ps['roleID'] = self.get_arg('role', '')
        ps['userGroupID'] = self.get_arg('userGroup', '')
        ps['deps'] = department_logic.query_all_by_active()
        msg = self.check_str_empty_input(user, ['name', 'realName', 'email', 'mobile', 'beginDate', 'endDate'])
        if str_helper.is_null_or_empty(msg) == False:
            ps['msg'] = msg
            ps = self.format_none_to_empty(ps)
            self.render('admin/user/add_or_edit.html', **ps)
            return

        user['user'] = self.get_oper_user()
        ps['user'] = copy.copy(user)
        if ps['isedit']:
            self.check_oper_right(right = state.operEdit)
            try:
                ou = user_logic.query_one_by_name(name = user['name'])
                info = user_logic.update(id = user['id'], realName = user['realName'], 
                        departmentID = user['departmentID'], parentID = user['parentID'], mobile = user['mobile'], 
                        tel = user['tel'], email = user['email'], status = user['status'], beginDate = user['beginDate'], 
                        endDate = user['endDate'], remark = user['remark'], user = user['user'])
                if info:
                    nu = user_logic.query_one_by_name(name = user['name'])
                    self.bind_role(userID = nu['id'], roleID = ps['roleID'], user = user['user'])
                    self.bind_user_group(userID = nu['id'], userGroupID = ps['userGroupID'], user = user['user'])
                    self.write_oper_log(action = 'userEdit', targetType = 1, targetID = str(nu['id']), targetName = nu['name'], startStatus = str_helper.json_encode(ou), endStatus= str_helper.json_encode(nu))
                    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.operEdit)            
            try:
                info = user_logic.add(name = user['name'], passWord = user['passWord'], 
                            realName = user['realName'], departmentID = user['departmentID'], mobile = user['mobile'], 
                            tel = user['tel'], email = user['email'],beginDate = user['beginDate'], 
                            endDate = user['endDate'], status = user['status'], remark = user['remark'], 
                            parentID = user['parentID'], user = user['user'])
                if info > 0:
                    nu = user_logic.query_one_by_name(name = user['name'])
                    self.bind_role(userID = nu['id'], roleID = ps['roleID'], user = user['user'])
                    self.bind_user_group(userID = nu['id'], userGroupID = ps['userGroupID'], user = user['user'])
                    self.write_oper_log(action = 'userCreate', targetType = 1, targetID = str(nu['id']), targetName = nu['name'], startStatus = '', endStatus= str_helper.json_encode(nu))
                    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/user/add_or_edit.html', **ps)
Exemplo n.º 6
0
    def post(self):
        ps = self.get_page_config(title='创建用户')
        ps['ResetPasswordType'] = self.check_oper_right_custom_right(
            self._rightKey, self._resetPwKey)
        if ps['isedit']:
            ps['title'] = self.get_page_title('编辑用户')

        user = self.get_args([
            'id', 'passWord', 'name', 'realName', 'mobile', 'tel', 'email',
            'remark', 'beginDate', 'endDate'
        ], '')
        user['status'] = int(self.get_arg('status', '0'))
        user['departmentID'] = int(self.get_arg('departmentID', '0'))
        user['parentID'] = int(self.get_arg('parentID', '0'))
        ps['user'] = user
        ps['userStatus'] = state.UserStatus
        ps['roleID'] = self.get_arg('role', '')
        ps['userGroupID'] = self.get_arg('userGroup', '')
        ps['deps'] = department_logic.query_all_by_active()
        msg = self.check_str_empty_input(
            user,
            ['name', 'realName', 'email', 'mobile', 'beginDate', 'endDate'])
        if str_helper.is_null_or_empty(msg) == False:
            ps['msg'] = msg
            ps = self.format_none_to_empty(ps)
            self.render('admin/user/add_or_edit_bs.html', **ps)
            return

        user['user'] = self.get_oper_user()
        ps['user'] = copy.copy(user)
        if ps['isedit']:
            self.check_oper_right(right=state.operEdit)
            try:
                ou = user_logic.query_one_by_name(name=user['name'])
                info = user_logic.update(id=user['id'],
                                         realName=user['realName'],
                                         departmentID=user['departmentID'],
                                         parentID=user['parentID'],
                                         mobile=user['mobile'],
                                         tel=user['tel'],
                                         email=user['email'],
                                         status=user['status'],
                                         beginDate=user['beginDate'],
                                         endDate=user['endDate'],
                                         remark=user['remark'],
                                         user=user['user'])
                if info:
                    nu = user_logic.query_one_by_name(name=user['name'])
                    self.bind_role(userID=nu['id'],
                                   roleID=ps['roleID'],
                                   user=user['user'])
                    self.bind_user_group(userID=nu['id'],
                                         userGroupID=ps['userGroupID'],
                                         user=user['user'])
                    self.write_oper_log(action='userEdit',
                                        targetType=1,
                                        targetID=str(nu['id']),
                                        targetName=nu['name'],
                                        startStatus=str_helper.json_encode(ou),
                                        endStatus=str_helper.json_encode(nu))
                    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.operEdit)
            try:
                info = user_logic.add(name=user['name'],
                                      passWord=user['passWord'],
                                      realName=user['realName'],
                                      departmentID=user['departmentID'],
                                      mobile=user['mobile'],
                                      tel=user['tel'],
                                      email=user['email'],
                                      beginDate=user['beginDate'],
                                      endDate=user['endDate'],
                                      status=user['status'],
                                      remark=user['remark'],
                                      parentID=user['parentID'],
                                      user=user['user'])
                if info > 0:
                    nu = user_logic.query_one_by_name(name=user['name'])
                    self.bind_role(userID=nu['id'],
                                   roleID=ps['roleID'],
                                   user=user['user'])
                    self.bind_user_group(userID=nu['id'],
                                         userGroupID=ps['userGroupID'],
                                         user=user['user'])
                    self.write_oper_log(action='userCreate',
                                        targetType=1,
                                        targetID=str(nu['id']),
                                        targetName=nu['name'],
                                        startStatus='',
                                        endStatus=str_helper.json_encode(nu))
                    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/user/add_or_edit_bs.html', **ps)