Bugzilla – Attachment 126903 Details for
Bug 29320
Use OverDrive availability API V2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29320: Update OverDrive availability to V2
Bug-29320-Update-OverDrive-availability-to-V2.patch (text/plain), 4.53 KB, created by
Nick Clemens (kidclamp)
on 2021-10-26 11:25:29 UTC
(
hide
)
Description:
Bug 29320: Update OverDrive availability to V2
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-10-26 11:25:29 UTC
Size:
4.53 KB
patch
obsolete
>From a1e3a58420a4bb2488d1749ee5e75403d5bb3eb5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 26 Oct 2021 11:22:04 +0000 >Subject: [PATCH] Bug 29320: Update OverDrive availability to V2 > >This patch updates the call to overdrive_proxy to allow passing a version >and updates the code to use V2 for availability > >To test: >1 - Enable OverDrive integration by setting the sysprefs >2 - Log in to your overdrive account in the Koha opac >3 - Perform a search and note availability display >4 - Confirm you can checkout/hold/return books >5 - Apply patch >6 - Repeat search and test functionality >7 - Note that title with '0 out of 0 copies available' now say 'Currently unavailable' >--- > .../bootstrap/en/modules/opac-overdrive-search.tt | 10 +++++++--- > koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js | 2 +- > opac/svc/overdrive_proxy | 3 ++- > 3 files changed, 10 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt >index 2a690c7696..96613d1f87 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt >@@ -78,13 +78,17 @@ > $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") ); > > KOHA.OverDrive.Get( >- prod.links.availability.href, >- {}, >+ prod.links.availabilityV2.href, >+ { version: 2}, > function ( data ) { > if ( data.error ) return; > > if( data.availabilityType == 'AlwaysAvailable' ){ > $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Always available") + '</b></span>' ); >+ } else if ( data.availabilityType == 'LimitedAvailability' && data.available ) { >+ $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Currently available") + '</b></span>' ); >+ } else if ( !data.available ) { >+ $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="unavailable"><b>' + _("Currently unavailable") + '</b></span>' ); > } else { > $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' ); > } >@@ -94,7 +98,7 @@ > } > > $tr.find( '.info' ).each(function() { >- KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable); >+ KOHA.OverDriveCirculation.add_actions(this, data.reserveId, data.copiesAvailable); > }); > } > ); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js >index 865946c350..92698f3bf2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js >@@ -11,7 +11,7 @@ KOHA.OverDrive = ( function() { > Get: function( url, params, callback ) { > $.ajax( { > type: 'GET', >- url: url.replace( /https?:\/\/api.overdrive.com\/v1/, proxy_base_url ), >+ url: url.replace( /https?:\/\/api.overdrive.com\/v[1|2]/, proxy_base_url ), > dataType: 'json', > data: params, > error: function( xhr, error ) { >diff --git a/opac/svc/overdrive_proxy b/opac/svc/overdrive_proxy >index 9df4d0cd07..9422079b7d 100755 >--- a/opac/svc/overdrive_proxy >+++ b/opac/svc/overdrive_proxy >@@ -59,10 +59,11 @@ if ( !(C4::Context->preference('OverDriveClientKey') && C4::Context->preference( > > exit; > } >+my $version = $query->param('version') // 1; > my $fixed_query = $query->query_string; > $fixed_query =~ tr/;/&/; > >-my $request = HTTP::Request::Common::GET( "https://api.overdrive.com/v1" . $query->path_info . '?' . $fixed_query ); >+my $request = HTTP::Request::Common::GET( "https://api.overdrive.com/v$version" . $query->path_info . '?' . $fixed_query ); > $request->header( Authorization => $token ); > > my $ua = LWP::UserAgent->new( "Koha " . Koha::version() ); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29320
:
126903
|
126920
|
128956