예제 #1
0
def list(request, response):
    data = {'title': '系统管理 - 组 - 列表'}
    page = request.get_param('page')
    size = request.get_param('size')
    keyword = request.get_param('keyword')
    data['keyword'] = keyword
    data['pagination'] = pzx.group.find(keyword, int(page) if page else 1, int(size) if size else Pagination.DEFAULT_PAGE_SIZE)
    webutil.render('/group/list.html', data, request, response)
예제 #2
0
def list(request, response):
    data = {"title": "系统管理 - 用户 - 列表"}
    page = request.get_param("page")
    size = request.get_param("size")
    keyword = request.get_param("keyword")
    data["keyword"] = keyword
    data["pagination"] = pzx.user.find(
        keyword, int(page) if page else 1, int(size) if size else Pagination.DEFAULT_PAGE_SIZE
    )
    webutil.render("/user/list.html", data, request, response)
예제 #3
0
def handle(e, request, response):
    response.reset()
    response.set_content_type('text/html; charset=%s' % request.get_encoding())
    
    # 认证异常
    if isinstance(e, AuthenticationException):
        url = request.get_ctx_path() + '/login?message=' + urllib.parse.quote(str(e), encoding=request.get_encoding())
        redirect = request.get_param(redirect_key)
        redirect = urllib.parse.quote(redirect, encoding=request.get_encoding()) if redirect else ''
        response.redirect(url + '&redirect=' +  redirect)
        return
    
    # 未登录访问了受保护的页面,重定向到登录页面
    if isinstance(e, UnAuthenticationException):
        login_redirect = request.get_path() if 'get' == request.get_method().lower() else request.get_header(referer_key)
        login_redirect = urllib.parse.quote(login_redirect, encoding=request.get_encoding()) if login_redirect else ''
        response.redirect(request.get_ctx_path() + '/login?redirect=' + login_redirect)
        return
    
    status = 500
    message = e
    # 找不到控制器
    if isinstance(e, NoHandlerFoundException):
        status = 404
        message = '您请求的资源[%s]不存在' % request.get_path()
        logging.error(message)
    
    # 不能处理对应的Http方法
    if isinstance(e, NoMethodFoundException):
        if request.get_method() in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT'):
            status = 405
        else:
            status = 501
        message = '资源[%s]不支持[%s]请求方法' % (request.get_path(), request.get_method())
        logging.error(message)
     
    if isinstance(e, AuthorizationException):
        status = 403
        
    # 输出错误页面
    webutil.render('/error.html', {'status': status, 'message': message}, request, response)
예제 #4
0
def edit_groups(request, response):
    data = {"title": "系统管理 - 用户 - 设置组"}
    id = re.search("\d+", request.get_path()).group(0)
    data["model"] = pzx.user.get(int(id))
    data["groups"] = pzx.group.list()
    webutil.render("/user/groups_edit.html", data, request, response)
예제 #5
0
def edit_password(request, response):
    data = {"title": "系统管理 - 用户 - 修改密码"}
    id = re.search("\d+", request.get_path()).group(0)
    data["model"] = pzx.user.get(int(id))
    webutil.render("/user/password_edit.html", data, request, response)
예제 #6
0
def get(request, response):
    data = {"title": "系统管理 - 用户 - 查看"}
    id = re.search("\d+", request.get_path()).group(0)
    data["model"] = pzx.user.get(int(id))
    webutil.render("/user/view.html", data, request, response)
예제 #7
0
def add(request, response):
    data = {"title": "系统管理 - 用户 - 创建", "parent_id": request.get_param("parent_id")}
    webutil.render("/user/add.html", data, request, response)
예제 #8
0
def get(request, response):
    webutil.render(
        '/login.html', 
        {'message': request.get_param('message'), 'redirect': request.get_param('redirect', request.get_header('referer', ''))}, 
        request, 
        response)
예제 #9
0
def edit_password(request, response):
    data = {'title': authholder.principal().get_prototype().name + ' - 密码 - 修改'}
    data['model'] = pzx.user.get_self(authholder.principal().get_prototype().id)
    webutil.render('/profile/password_edit.html', data, request, response)
예제 #10
0
def edit(request, response):
    data = {'title': authholder.principal().get_prototype().name + ' - 个人信息 - 修改'}
    data['model'] = pzx.user.get(authholder.principal().get_prototype().id)
    webutil.render('/profile/edit.html', data, request, response)
예제 #11
0
def get(request, response):
    webutil.render('/blog/index.html', {'title': '日志'}, request, response)
    
예제 #12
0
def edit_roles(request, response):
    data = {'title': '系统管理 - 组 - 设置角色'}
    id = re.search('\d+', request.get_path()).group(0)
    data['model'] = pzx.group.get(int(id))
    data['roles'] = pzx.role.list()
    webutil.render('/group/roles_edit.html', data, request, response)
예제 #13
0
def edit(request, response):
    data = {'title': '系统管理 - 组 - 修改'}
    id = re.search('\d+', request.get_path()).group(0)
    data['model'] = pzx.group.get(int(id))
    webutil.render('/group/edit.html', data, request, response)
예제 #14
0
def add(request, response):
    data = {'title': '系统管理 - 组 - 创建', 'parent_id': request.get_param('parent_id')}
    webutil.render('/group/add.html', data, request, response)