Ejemplo n.º 1
0
def make_saved_request(request, request_id=''):
    saved_request = get_object_or_404(SavedRequest,id=request_id, user = request.user)


    (zgate_form, cookies) = zworker.get_zgate_form(
        zgate_url=saved_request.zcatalog.url,
        xml=saved_request.zcatalog.xml,
        xsl=saved_request.zcatalog.xsl,
        cookies=request.COOKIES
        #        username=username,
        #        password=password
    )
    session_id = zworker.get_zgate_session_id(zgate_form)
    get_params = []
    get_params.append(urlquote('zstate') + '=' + urlquote('action'))
    get_params.append(urlquote('ACTION') + '=' + urlquote('SEARCH'))
    get_params.append(urlquote('SESSION_ID') + '=' + urlquote(session_id))
    get_params.append(urlquote('LANG') + '=' + urlquote(saved_request.zcatalog.default_lang))
    get_params.append(urlquote('DBNAME') + '=' + urlquote(saved_request.zurls))
    get_params.append(urlquote('TERM_1') + '=' + urlquote(saved_request.query))
    get_params.append(urlquote('ESNAME') + '=' + urlquote('B'))
    get_params.append(urlquote('MAXRECORDS') + '=' + urlquote('20'))
    get_params.append(urlquote('CHAR_SET') + '=' + urlquote('UTF-8'))
    get_params.append(urlquote('RECSYNTAX') + '=' + urlquote('1.2.840.10003.5.28'))

    link = reverse('zgate:zgate_index', args=(saved_request.zcatalog.id,)) + '?' + '&'.join(get_params)

    response = redirect(link)
    return set_cookies_to_response(cookies, response)
Ejemplo n.º 2
0
def draw_order(request, catalog_id='', slug=''):
    catalog = None
    if catalog_id:
        catalog = get_object_or_404(ZCatalog, id=catalog_id)
    elif slug:
        catalog = get_object_or_404(ZCatalog, latin_title=slug)
    else:
        raise Http404()

    id = request.GET.get('id', None)
    if not id:
        raise Http404()


    (zgate_form, cookies) = zworker.get_zgate_form(
        zgate_url=catalog.url,
        xml=catalog.xml,
        xsl=catalog.xsl,
        cookies=request.COOKIES,
        username='******',
        password='******',
    )
    session_id = zworker.get_zgate_session_id(zgate_form)
    form_params =  zworker.get_form_dict(zgate_form)
    del(form_params['scan'])
    form_params['use_1']='12:1.2.840.10003.3.1'
    form_params['term_1']= id
    result = zworker.request(catalog.url, data=form_params, cookies=cookies)

    if  result[0].decode('utf-8').find(u'id="%s' % (id,)) >= 0:
        link = catalog.url + '?preorder+%s+1+default+1+1.2.840.10003.5.28+rus' % session_id
        return redirect(link)
    return HttpResponse(u'Ok')
Ejemplo n.º 3
0
def draw_order(request, catalog_id='', slug=''):
    catalog = None
    if catalog_id:
        catalog = get_object_or_404(ZCatalog, id=catalog_id)
    elif slug:
        catalog = get_object_or_404(ZCatalog, latin_title=slug)
    else:
        raise Http404()

    id = request.GET.get('id', None)
    if not id:
        raise Http404()

    (zgate_form, cookies) = zworker.get_zgate_form(
        zgate_url=catalog.url,
        xml=catalog.xml,
        xsl=catalog.xsl,
        cookies=request.COOKIES,
        username='******',
        password='******',
    )
    session_id = zworker.get_zgate_session_id(zgate_form)
    form_params = zworker.get_form_dict(zgate_form)
    del (form_params['scan'])
    form_params['use_1'] = '12:1.2.840.10003.3.1'
    form_params['term_1'] = id
    result = zworker.request(catalog.url, data=form_params, cookies=cookies)

    if result[0].decode('utf-8').find(u'id="%s' % (id, )) >= 0:
        link = catalog.url + '?preorder+%s+1+default+1+1.2.840.10003.5.28+rus' % session_id
        return redirect(link)
    return HttpResponse(u'Ok')
Ejemplo n.º 4
0
def make_saved_request(request, request_id=''):
    saved_request = get_object_or_404(SavedRequest,
                                      id=request_id,
                                      user=request.user)

    (zgate_form, cookies) = zworker.get_zgate_form(
        zgate_url=saved_request.zcatalog.url,
        xml=saved_request.zcatalog.xml,
        xsl=saved_request.zcatalog.xsl,
        cookies=request.COOKIES
        #        username=username,
        #        password=password
    )
    session_id = zworker.get_zgate_session_id(zgate_form)
    get_params = []
    get_params.append(urlquote('zstate') + '=' + urlquote('action'))
    get_params.append(urlquote('ACTION') + '=' + urlquote('SEARCH'))
    get_params.append(urlquote('SESSION_ID') + '=' + urlquote(session_id))
    get_params.append(
        urlquote('LANG') + '=' + urlquote(saved_request.zcatalog.default_lang))
    get_params.append(urlquote('DBNAME') + '=' + urlquote(saved_request.zurls))
    get_params.append(urlquote('TERM_1') + '=' + urlquote(saved_request.query))
    get_params.append(urlquote('ESNAME') + '=' + urlquote('B'))
    get_params.append(urlquote('MAXRECORDS') + '=' + urlquote('20'))
    get_params.append(urlquote('CHAR_SET') + '=' + urlquote('UTF-8'))
    get_params.append(
        urlquote('RECSYNTAX') + '=' + urlquote('1.2.840.10003.5.28'))

    link = reverse('zgate:zgate_index', args=(
        saved_request.zcatalog.id, )) + '?' + '&'.join(get_params)

    response = redirect(link)
    return set_cookies_to_response(cookies, response)
Ejemplo n.º 5
0
def simple_search(request):
    q = request.GET.get('text', None)
    if q:
        zcatalog = get_object_or_404(ZCatalog, latin_title='allbases')
        (zgate_form, cookies) = zworker.get_zgate_form(
            zgate_url=zcatalog.url,
            xml=zcatalog.xml,
            xsl=zcatalog.xsl,
            entry_point='/',
            cookies=request.COOKIES
        )
        session_id = zworker.get_zgate_session_id(zgate_form)
        get_params = []
        get_params.append(urlquote('zstate') + '=' + urlquote('action'))
        get_params.append(urlquote('ACTION') + '=' + urlquote('SEARCH'))
        get_params.append(urlquote('SESSION_ID') + '=' + urlquote(session_id))
        get_params.append(urlquote('LANG') + '=' + urlquote(zcatalog.default_lang))
        get_params.append(urlquote('DBNAME') + '=' + urlquote('books,pokrovsk_br,civil_press,languages,notes,periodics,analytics,arts,staff,kraychel,ural_el'))

        get_params.append(urlquote('TERM_1') + '=' + urlquote('%s[1,4:1.2.840.10003.3.1,2,0,4,0,5,1]' % q))
        get_params.append(urlquote('ESNAME') + '=' + urlquote('B'))
        get_params.append(urlquote('MAXRECORDS') + '=' + urlquote('20'))
        get_params.append(urlquote('CHAR_SET') + '=' + urlquote('UTF-8'))
        get_params.append(urlquote('RECSYNTAX') + '=' + urlquote('1.2.840.10003.5.28'))

        link = reverse('zgate_slug_index', args=(zcatalog.latin_title,)) + '?' + '&'.join(get_params)

        response = redirect(link)
        return set_cookies_to_response(cookies, response)
    else:
        return HttpResponse(u'Указаны неправильные параметры')