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)
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)
def item_json(request, bibid, z3950='False', school=None): try: bib_data = voyager.get_bib_data(bibid) if not bib_data: return HttpResponse('{}', content_type='application/json', status=404) bib_data['openurl'] = _openurl_dict(request) bib_data['holdings'] = voyager.get_holdings(bib_data) 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') except DatabaseError: logger.exception('unable to render bibid json: %s' % bibid) return error500(request)
def item(request, bibid): bib = None try: bib = voyager.get_bib_data(bibid) if not bib: return render(request, '404.html', {'num': bibid, '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) if holdings: holdings = strip_bad_holdings(holdings) holdings = add_floormap_link(holdings) show_ill_link = display_ill_link(holdings) ours, theirs, shared = splitsort(callnumsort(enumsort(holdings))) holdings = elecsort(holdsort(templocsort(availsort(ours)))) \ + elecsort(holdsort(templocsort(availsort(shared)))) \ + libsort(elecsort(holdsort(templocsort(availsort(theirs))), rev=True)) else: show_ill_link = False # extract details for easy display in a separate tab details = [] for name, display_name, specs in marc.mapping: if name in bib and len(bib[name]) > 0: details.append((display_name, bib[name])) bibs = voyager.get_all_bibs(bib['BIB_ID_LIST']) bib['RELATED_ISBN_LIST'] = list(set(voyager.get_related_isbns(bibs))) return render(request, 'item.html', { 'bibid': bibid, 'bib': bib, 'holdings': holdings, 'link': bib.get('LINK', [])[9:], 'show_ill_link': show_ill_link, 'non_wrlc_item': False, 'details': details, 'max_periodicals': settings.MAX_PERIODICALS, }) except: logger.exception('unable to render bibid: %s' % bibid) return error500(request)
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)
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)
def handle(self, *args, **options): if len(args) >= 1: bib = v.get_bib_data(args[0]) h = v.get_holdings(bib )