예제 #1
0
파일: views.py 프로젝트: isergey/libcms
def render_search_result(request, catalog, zresult=''):
    cookies = {}
    if zresult == '':
        url = catalog.url
        new_get = []
        for key in request.GET:
            if key == 'zstate': continue
            new_get.append(urlquote(key) + '=' + urlquote(request.GET[key]))

        new_get = '&'.join(new_get)

        if request.GET['zstate'] == 'action':
            url = url + '?' + new_get
        else:
            url = url + '?' + request.GET['zstate'].replace(' ', '+')

        (zresult, cookies) = zworker.request(url, cookies=request.COOKIES)
    try:
        zresults_body_element = zworker.get_body_element(zresult)
        zresults_body_element = zworker.change_form_action(zresults_body_element)

        zresults_body_element = zworker.change_links_href(zresults_body_element)
    except Exception:
        return HttpResponse(u'Некорректный url')
    result = zworker.make_html_body_content(zresults_body_element)

    response = render(request, 'zgate/search_results.html', {
        'catalog_title': catalog.title,
        'search_results': result
    })

    return  set_cookies_to_response(cookies, response)
예제 #2
0
def render_search_result(request, catalog, zresult=''):
    cookies = {}
    if zresult == '':
        url = catalog.url
        new_get = []
        for key in request.GET:
            if key == 'zstate': continue
            new_get.append(urlquote(key) + '=' + urlquote(request.GET[key]))

        new_get = '&'.join(new_get)

        if request.GET['zstate'] == 'action':
            url = url + '?' + new_get
        else:
            url = url + '?' + request.GET['zstate'].replace(' ', '+')

        (zresult, cookies) = zworker.request(url, cookies=request.COOKIES)
    try:
        zresults_body_element = zworker.get_body_element(zresult)
        zresults_body_element = zworker.change_form_action(
            zresults_body_element)

        zresults_body_element = zworker.change_links_href(
            zresults_body_element)
    except Exception:
        return HttpResponse(u'Некорректный url')
    result = zworker.make_html_body_content(zresults_body_element)

    response = render(request, 'zgate/search_results.html', {
        'catalog_title': catalog.title,
        'search_results': result
    })

    return set_cookies_to_response(cookies, response)
예제 #3
0
파일: views.py 프로젝트: isergey/libcms
def render_form(request, zresult, catalog):
    zworker.entry_point = reverse("zgate_index", args=[catalog.id])
    page_body = zworker.get_body_element(zresult)
    page_body = zworker.change_links_href(page_body)
    page_body = zworker.change_form_action(page_body)
    page_body = zworker.make_html_body_content(page_body)

    return render(request, 'zgate/search_form.html',
            {'catalog_title': catalog.title,
             'search_form': page_body,
             'catalog': catalog})
예제 #4
0
def render_form(request, zresult, catalog):
    zworker.entry_point = reverse("zgate_index", args=[catalog.id])
    page_body = zworker.get_body_element(zresult)
    page_body = zworker.change_links_href(page_body)
    page_body = zworker.change_form_action(page_body)
    page_body = zworker.make_html_body_content(page_body)

    return render(
        request, 'zgate/search_form.html', {
            'catalog_title': catalog.title,
            'search_form': page_body,
            'catalog': catalog
        })