Exemplo n.º 1
0
def app(request):
    """
    Returns responsive app view for the Call Number App
    """
    call_number=request.REQUEST.get('call_number',None)
    if call_number is not None:
        current = redis_helpers.get_record(call_number=call_number)
    else:
        current = setup_seed_rec()
    call_number = current.get('call_number')
    next_recs = redis_helpers.get_next(call_number,
                                       call_number_type=current['type_of'])
    print(next_recs)
    previous_recs = redis_helpers.get_previous(call_number,
                                               call_number_type=current['type_of'])
    return direct_to_template(request,
                              'call_number/app.html',
                             {'app':APP,
                              'aristotle_url':settings.DISCOVERY_RECORD_URL,
                              'current':current,
			      'feedback_context':request.get_full_path(),
			      'feedback_form':FeedbackForm({'subject':'Call Number App'}),
                              'institution':settings.INSTITUTION,
                              'next':next_recs,
                              'previous':previous_recs,
                              'redis':redis_helpers.redis_server.info(),
                              'typeahead_data':None})
Exemplo n.º 2
0
def term_search(request):
    """
     JSON view that outputs a list of record's legacy bib numbers in JSON

    :param request: Djagno HTTP Request
    """
    call_number=request.REQUEST.get('call_number')
    if request.REQUEST.has_key("type"):
        call_number_type = request.REQUEST.get('type')
    else:
        call_number_type = "lccn"
    if request.REQUEST.has_key("slice-size"):
        slice_size = int(request.REQUEST.get('slice-size'))
    else:
        slice_size = 2 # Default assumes browse display of two results
    current = redis_helpers.get_record(call_number=call_number)
    bib_numbers = []
    if current is not None:
        bib_numbers.append(current.get('bib_number'))
        current_rank = redis_helpers.get_rank(call_number,
                                              call_number_type=call_number_type)

        next_recs = redis_helpers.get_slice(current_rank+1,
                                            current_rank+slice_size,
                                            call_number_type)
        for row in next_recs:
            bib_numbers.append(row.get('bib_number'))
        previous_recs = redis_helpers.get_previous(call_number,
                                                   call_number_type=call_number_type)
        for row in previous_recs:
            bib_numbers.insert(0,row.get('bib_number'))
    return {'bib_numbers':bib_numbers}
Exemplo n.º 3
0
def app(request):
    """
    Returns responsive app view for the Call Number App
    """

    try:
        current = redis_helpers.get_record(call_number=request.REQUEST.get('call_number'))
    except:
        print("{0}".format(sys.exc_info()))
        current = setup_seed_rec()
    call_number = current.get('call_number')
    next_recs = redis_helpers.get_next(call_number,
                                      call_number_type=current['type_of'])
    previous_recs = redis_helpers.get_previous(call_number,
                                               call_number_type=current['type_of'])
    return direct_to_template(request,
                              'call_number/app.html',
                             {'app':APP,
                              'aristotle_url':settings.DISCOVERY_RECORD_URL,
                              'current':current,
                              'institution':settings.INSTITUTION, 
                              'next':next_recs,
                              'previous':previous_recs,
                              'redis':redis_helpers.redis_server.info(),
                              'typeahead_data':None})
Exemplo n.º 4
0
def default(request):
    """
    Returns the default view for the Call Number Application
    """
    ## return HttpResponse("Call Number Application index")
    seed_key = '{0}:identifiers'.format(SEED_RECORD_ID)
    current = redis_server.hgetall()
    return direct_to_template(request,
                              'call_number/default.html',
                              {'aristotle_url':settings.DISCOVERY_RECORD_URL,
                               'current':current,
                               'next':redis_helpers.get_next(current['lccn']),
                               'previous':redis_helpers.get_previous(current['lccn']),
                               'redis':redis_helpers.redis_server.info()})
Exemplo n.º 5
0
def browse(request):
    """
    JSON view for a call number browser widget view

    :param request: HTTP Request
    """
    call_number = request.GET['call_number']
    current = redis_helpers.get_record(call_number=call_number)
    next_recs = redis_helpers.get_next(call_number)
    previous_recs = redis_helpers.get_previous(call_number)
    context = Context({'aristotle_url':settings.DISCOVERY_RECORD_URL,
                       'current':current,
                       'next':next_recs,
                       'previous':previous_recs})
    widget_template = loader.get_template('call_number/snippets/widget.html')
    return {'html':widget_template.render(context)}
Exemplo n.º 6
0
def widget(request):
    """
    Returns rendered html snippet of call number browser widget
    """
    standalone = False
    call_number = 'PS21 .D5185 1978'
    if 'standalone' in request.REQUEST:
        standalone = request.REQUEST.get('standalone')
    if 'call_number' in request.REQUEST:
        call_number = request.REQUEST.get('call_number')
    current = redis_helpers.get_record(call_number=call_number)
    return direct_to_template(request,
                              'call_number/snippets/widget.html',
                              {'aristotle_url': settings.DISCOVERY_RECORD_URL,
                               'current': current,
                               'next': redis_helpers.get_next(call_number),
                               'previous': redis_helpers.get_previous(
                                   call_number),
                               'standalone': standalone})
Exemplo n.º 7
0
def widget_search(request):
    """
    JSON view for widget search on call number

    :param request: Request
    """
    call_number = request.REQUEST.get('q')
    if "type" in request.REQUEST:
        call_number_type = request.REQUEST.get('type')
    else:
        call_number_type = "lcc"
    current = redis_helpers.get_record(call_number=call_number,
                                       call_number_type=call_number_type)
    next_recs = redis_helpers.get_next(call_number, call_number_type)
    previous_recs = redis_helpers.get_previous(call_number, call_number_type)
    return {
        'current': current,
        'nextRecs': next_recs,
        'previousRecs': previous_recs
        }
Exemplo n.º 8
0
def widget(request):
    """
    Returns rendered html snippet of call number browser widget
    """
    standalone = False
    call_number = 'PS21 .D5185 1978'
    if request.method == 'POST':
        if request.POST.has_key('standalone'):
            standalone = request.POST['standalone']
        if request.POST.has_key('call_number'):
            call_number = request.POST['call_number']
    else:
         if request.GET.has_key('standalone'):
            standalone = request.GET['standalone']
         if request.GET.has_key('call_number'):
            call_number = request.GET['call_number']
    current = redis_helpers.get_record(call_number=call_number)
    return direct_to_template(request,
                              'call_number/snippets/widget.html',
                              {'aristotle_url':settings.DISCOVERY_RECORD_URL,
                               'current':current,
                               'next':redis_helpers.get_next(call_number),
                               'previous':redis_helpers.get_previous(call_number),
                               'standalone':standalone})