コード例 #1
0
ファイル: views.py プロジェクト: pombredanne/launchpad-1
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)
コード例 #2
0
ファイル: views.py プロジェクト: pombredanne/launchpad-1
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)
コード例 #3
0
ファイル: views.py プロジェクト: leighannskeen/launchpad
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)
コード例 #4
0
ファイル: views.py プロジェクト: leighannskeen/launchpad
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)