Exemple #1
0
def gmitem(request, gmbibid):
    try:
        bibid = voyager.get_wrlcbib_from_gmbib(gmbibid)
        if bibid:
            return redirect('item', bibid=bibid)
        else:
            bib = voyager.get_z3950_bib_data(gmbibid, 'GM')
            if not bib:
                return render(request,
                              '404.html', {
                                  'num': gmbibid,
                                  'num_type': 'BIB ID'
                              },
                              status=404)
            bib['openurl'] = _openurl_dict(request)
            bib['citation_json'] = citation_json(request)
            # Ensure bib data is ours if possible
            if not bib['LIBRARY_NAME'] == settings.PREF_LIB:
                for alt_bib in bib['BIB_ID_LIST']:
                    if alt_bib['LIBRARY_NAME'] == settings.PREF_LIB:
                        return item(request, alt_bib['BIB_ID'])
            holdings = voyager.get_holdings(bib, 'GM', False)
            if holdings:
                holdings = strip_bad_holdings(holdings)
                show_wrlc_link = False
                ours, theirs, shared = splitsort(
                    callnumsort(enumsort(holdings)))
                holdings = elecsort(availsort(ours)) \
                    + elecsort(availsort(shared)) \
                    + libsort(elecsort(availsort(theirs), rev=True))
            return render(
                request, 'item.html', {
                    'bibid': bibid,
                    'bib': bib,
                    'debug': settings.DEBUG,
                    'title_chars': settings.TITLE_CHARS,
                    'title_leftover_chars': settings.TITLE_LEFTOVER_CHARS,
                    'holdings': holdings,
                    'link': bib.get('LINK', [])[9:],
                    'google_analytics_ua': settings.GOOGLE_ANALYTICS_UA,
                    'link_resolver': settings.LINK_RESOLVER,
                    'enable_humans': settings.ENABLE_HUMANS,
                    'audio_tags': settings.STREAMING_AUDIO_TAGS,
                    'video_tags': settings.STREAMING_VIDEO_TAGS,
                    'max_items': settings.MAX_ITEMS,
                    'show_wrlc_link': show_wrlc_link,
                    'non_wrlc_item': True
                })
        return render(request,
                      '404.html', {
                          'num': gmbibid,
                          'num_type': 'George Mason BIB ID'
                      },
                      status=404)
    except DatabaseError:
        logger.exception('unable to render gmbibid: %s' % gmbibid)
        return error500(request)
Exemple #2
0
def gmitem(request, gmbibid):
    try:
        bibid = voyager.get_wrlcbib_from_gmbib(gmbibid)
        if bibid:
            return redirect('item', bibid=bibid)
        else:
            bib = voyager.get_z3950_bib_data(gmbibid, 'GM')
            if not bib:
                return render(request, '404.html', {'num': gmbibid,
                              'num_type': 'BIB ID'}, status=404)
            bib['openurl'] = _openurl_dict(request)
            bib['citation_json'] = citation_json(request)
            # Ensure bib data is ours if possible
            if not bib['LIBRARY_NAME'] == settings.PREF_LIB:
                for alt_bib in bib['BIB_ID_LIST']:
                    if alt_bib['LIBRARY_NAME'] == settings.PREF_LIB:
                        return item(request, alt_bib['BIB_ID'])
            holdings = voyager.get_holdings(bib, 'GM', False)
            if holdings:
                holdings = strip_bad_holdings(holdings)
                show_wrlc_link = False
                ours, theirs, shared = splitsort(callnumsort(enumsort(
                    holdings)))
                holdings = elecsort(availsort(ours)) \
                    + elecsort(availsort(shared)) \
                    + libsort(elecsort(availsort(theirs), rev=True))
            return render(request, 'item.html', {
                'bibid': bibid,
                'bib': bib,
                'debug': settings.DEBUG,
                'title_chars': settings.TITLE_CHARS,
                'title_leftover_chars': settings.TITLE_LEFTOVER_CHARS,
                'holdings': holdings,
                'link': bib.get('LINK', [])[9:],
                'google_analytics_ua': settings.GOOGLE_ANALYTICS_UA,
                'link_resolver': settings.LINK_RESOLVER,
                'enable_humans': settings.ENABLE_HUMANS,
                'audio_tags': settings.STREAMING_AUDIO_TAGS,
                'video_tags': settings.STREAMING_VIDEO_TAGS,
                'max_items': settings.MAX_ITEMS,
                'show_wrlc_link': show_wrlc_link,
                'non_wrlc_item': True
            })
        return render(request, '404.html', {'num': gmbibid,
                      'num_type': 'George Mason BIB ID'}, status=404)
    except DatabaseError:
        logger.exception('unable to render gmbibid: %s' % gmbibid)
        return error500(request)
Exemple #3
0
def gmitem(request, gmbibid):
    try:
        bibid = db.get_bibid_from_gmid(gmbibid)
        if bibid:
            return redirect('item', bibid=bibid)
        else:
            bib = voyager.get_z3950_bib_data(gmbibid, 'GM')
            if not bib:
                return render(request, '404.html', {'num': gmbibid,
                                                    'num_type': 'BIB ID'}, status=404)
            bib['openurl'] = _openurl_dict(request)
            bib['citation_json'] = citation_json(request)
            # Ensure bib data is ours if possible
            if not bib['LIBRARY_NAME'] == settings.PREF_LIB:
                for alt_bib in bib['BIB_ID_LIST']:
                    if alt_bib['LIBRARY_NAME'] == settings.PREF_LIB:
                        return item(request, alt_bib['BIB_ID'])
            holdings = voyager.get_holdings(bib, 'GM', False)
            if holdings:
                holdings = strip_bad_holdings(holdings)
                show_wrlc_link = False
                ours, theirs, shared = splitsort(callnumsort(enumsort(
                    holdings)))
                holdings = elecsort(availsort(ours)) \
                           + elecsort(availsort(shared)) \
                           + libsort(elecsort(availsort(theirs), rev=True))
                try:
                    linkval = bib.get('LINK', [])[9:]
                except:
                    linkval = ''
            return render(request, 'item.html', {
                'bibid': bibid,
                'bib': bib,
                'holdings': holdings,
                'link': linkval,
                'show_wrlc_link': show_wrlc_link,
                'non_wrlc_item': True
            })
        return render(request, '404.html', {'num': gmbibid,
                                            'num_type': 'George Mason BIB ID'}, status=404)
    except DatabaseError:
        logger.exception('unable to render gmbibid: %s' % gmbibid)
        return error500(request)
Exemple #4
0
def gmitem_json(request, gmbibid):
    try:
        bibid = voyager.get_bibid_from_gmid(gmbibid)
        if bibid:
            return redirect('item_json', bibid=bibid)
        else:
            bib_data = voyager.get_z3950_bib_data(gmbibid, 'GM')
            if not bib_data:
                return HttpResponse('{}', content_type='application/json',
                                    status=404)
            bib_data['holdings'] = voyager.get_holdings(bib_data, 'GM', False)
            bib_data['openurl'] = _openurl_dict(request)
            bib_data['citation_json'] = citation_json(request)
            bib_encoded = unicode_data(bib_data)
            return HttpResponse(json.dumps(bib_encoded, default=_date_handler,
                                           indent=2), content_type='application/json')
        raise Http404
    except DatabaseError:
        logger.exception('unable to render gmbibid json: %s' % gmbibid)
        return error500(request)