From 5916da9791893fc80e5b41f230e02cdb957179bd Mon Sep 17 00:00:00 2001 From: Matt Connolly Date: Thu, 15 Aug 2024 14:52:03 -0400 Subject: [PATCH 1/5] DACCESS-261: Rely on new version of cul-folio-edge (#109) * FOLIO token changes, authenticate returns a token expiration * Require latest version of cul_folio_edge; remove borrow_direct dependency (DACCESS-261) * Formatting * Remove 'newcatalog' references * Remove 'newcatalog' references --------- Co-authored-by: Melissa Wallace Co-authored-by: Sarah Chintomby --- Gemfile | 4 ++-- app/controllers/my_account/account_controller.rb | 7 ++++--- app/helpers/my_account/my_account_helper.rb | 2 +- app/views/my_account/account/_fines.html.haml | 2 +- lib/my_account/version.rb | 2 +- my_account.gemspec | 15 +++++++-------- release_notes.md | 8 ++++++++ 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 2a6e126..81d8178 100644 --- a/Gemfile +++ b/Gemfile @@ -16,5 +16,5 @@ gemspec gem 'rails', '~>6.1' gem 'unf_ext' -#gem 'cul-folio-edge', :path => '/Users/matt/code/cul/d&a/cul-folio-edge' -gem 'cul-folio-edge', :git => 'https://github.com/cul-it/cul-folio-edge' \ No newline at end of file +# gem 'cul-folio-edge', :path => '/Users/matt/code/cul/d&a/cul-folio-edge' +gem 'cul-folio-edge', git: 'https://github.com/cul-it/cul-folio-edge' diff --git a/app/controllers/my_account/account_controller.rb b/app/controllers/my_account/account_controller.rb index 7941421..ca7782c 100644 --- a/app/controllers/my_account/account_controller.rb +++ b/app/controllers/my_account/account_controller.rb @@ -62,9 +62,9 @@ def index end # Return a FOLIO authentication token for API calls -- either from the session if a token - # was prevoiusly created, or directly from FOLIO otherwise. + # was previously created, or has expired, or directly from FOLIO otherwise. def folio_token - if session[:folio_token].nil? + if session[:folio_token].nil? || (session[:folio_token_exp].present? && Time.now > Time.parse(session[:folio_token_exp])) url = ENV['OKAPI_URL'] tenant = ENV['OKAPI_TENANT'] response = CUL::FOLIO::Edge.authenticate(url, tenant, ENV['OKAPI_USER'], ENV['OKAPI_PW']) @@ -72,6 +72,7 @@ def folio_token Rails.logger.error "MyAccount error: Could not create a FOLIO token for #{user}" else session[:folio_token] = response[:token] + session[:folio_token_exp] = response[:token_exp] end end session[:folio_token] @@ -277,7 +278,7 @@ def ajax_catalog_link_and_source # FOLIO. A FOLIO source indicates that this was a locally-created record -- e.g., for a temporary record # for a BD/ReShare item. Most of the others appear to be MARC-source. This is probably not entirely accurate, # but we can filter out the FOLIO records and probably get things right most of the time. - link = "https://newcatalog.library.cornell.edu/catalog/#{response[:instance]['hrid']}" if source == 'MARC' + link = "https://catalog.library.cornell.edu/catalog/#{response[:instance]['hrid']}" if source == 'MARC' end render json: { link: link, source: source } end diff --git a/app/helpers/my_account/my_account_helper.rb b/app/helpers/my_account/my_account_helper.rb index 031e92c..bfbd979 100644 --- a/app/helpers/my_account/my_account_helper.rb +++ b/app/helpers/my_account/my_account_helper.rb @@ -14,7 +14,7 @@ def cased_title_link item # but indicates an actual library location for Voyager records. # item['lo'] == '' || item['TransactionNumber'] ? # display_title : - # link_to(display_title, "https://newcatalog.library.cornell.edu/catalog/#{item['bid']}") + # link_to(display_title, "https://catalog.library.cornell.edu/catalog/#{item['bid']}") end # Return a user-readable item status message. This will filter out the 'pahr' statuses that turn diff --git a/app/views/my_account/account/_fines.html.haml b/app/views/my_account/account/_fines.html.haml index 0d6e845..c0f4a1f 100644 --- a/app/views/my_account/account/_fines.html.haml +++ b/app/views/my_account/account/_fines.html.haml @@ -21,4 +21,4 @@ %td = number_to_currency(f['chargeAmount']['amount']) %p -= link_to "View fine rates", "https://newcatalog.library.cornell.edu/myaccount/login" \ No newline at end of file += link_to "View fine rates", "https://catalog.library.cornell.edu/myaccount/login" \ No newline at end of file diff --git a/lib/my_account/version.rb b/lib/my_account/version.rb index a445c5b..975c6ba 100644 --- a/lib/my_account/version.rb +++ b/lib/my_account/version.rb @@ -1,3 +1,3 @@ module MyAccount - VERSION = "2.2.5" + VERSION = '2.3' end diff --git a/my_account.gemspec b/my_account.gemspec index 0becc0c..7f4a987 100644 --- a/my_account.gemspec +++ b/my_account.gemspec @@ -1,7 +1,7 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: -require "my_account/version" +require 'my_account/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| @@ -9,20 +9,19 @@ Gem::Specification.new do |s| s.version = MyAccount::VERSION s.authors = ["Matt Connolly"] s.email = ["mjc12@cornell.edu"] - s.homepage = "http://newcatalog.library.cornell.edu/myaccount" - s.summary = "Summary of MyAccount." - s.description = "Description of MyAccount." + s.homepage = "http://catalog.library.cornell.edu/myaccount" + s.summary = "User account page for Cornell University Library online catalog" + s.description = "Provides a user account page for the Cornell University Library online catalog, including user account information, loans, requests, and fines." s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] - s.add_dependency "rails", "~> 6.1" + s.add_dependency 'rails', '~> 6.1' s.add_dependency 'blacklight',['>= 7.0'] - s.add_dependency "xml-simple" + s.add_dependency 'xml-simple' s.add_dependency 'rest-client' - s.add_dependency 'borrow_direct' - s.add_dependency 'cul-folio-edge', ['>= 1.2.1'] + s.add_dependency 'cul-folio-edge', '~3.1' s.add_development_dependency "sqlite3" end diff --git a/release_notes.md b/release_notes.md index 77d4adc..9e26d15 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,13 @@ # Release Notes - my-account +## [2.3] - 2024-08-12 + +### Changed +- Require v3.1 of `cul-folio-edge` to use new authentication tokens (DACCESS-261) +- Update catalog links to remove obsolete `newcatalog` qualifier + +### Removed +- Obsolete dependency on `borrow_direct` ## v2.2.5 - Change spelling of "Borrow Direct" to "BorrowDirect" From e846a67c8f342b259e1591499d869c7cbfbf96f4 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Tue, 20 Aug 2024 17:23:25 -0400 Subject: [PATCH 2/5] v2.3.1 - Fix bug in gemspec specification --- lib/my_account/version.rb | 2 +- my_account.gemspec | 2 +- release_notes.md | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/my_account/version.rb b/lib/my_account/version.rb index 975c6ba..abeebc5 100644 --- a/lib/my_account/version.rb +++ b/lib/my_account/version.rb @@ -1,3 +1,3 @@ module MyAccount - VERSION = '2.3' + VERSION = '2.3.1' end diff --git a/my_account.gemspec b/my_account.gemspec index 7f4a987..05b9530 100644 --- a/my_account.gemspec +++ b/my_account.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_dependency 'blacklight',['>= 7.0'] s.add_dependency 'xml-simple' s.add_dependency 'rest-client' - s.add_dependency 'cul-folio-edge', '~3.1' + s.add_dependency 'cul-folio-edge', '~> 3.1' s.add_development_dependency "sqlite3" end diff --git a/release_notes.md b/release_notes.md index 9e26d15..43502a9 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,10 @@ # Release Notes - my-account +## [2.3.1] - 2024-08-20 + +### Fixed +- Bad gemspec requirement for `cul-folio-edge` causing bundler to fail + ## [2.3] - 2024-08-12 ### Changed From 9bb8ea2591124d81fc5de508ca380f6c4aef96fd Mon Sep 17 00:00:00 2001 From: Matt Connolly Date: Mon, 26 Aug 2024 16:50:41 -0400 Subject: [PATCH 3/5] Fix caching problem with new FOLIO auth scheme (#112) --- app/controllers/my_account/account_controller.rb | 7 +++++-- lib/my_account/version.rb | 2 +- release_notes.md | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/my_account/account_controller.rb b/app/controllers/my_account/account_controller.rb index ca7782c..73dc972 100644 --- a/app/controllers/my_account/account_controller.rb +++ b/app/controllers/my_account/account_controller.rb @@ -63,8 +63,11 @@ def index # Return a FOLIO authentication token for API calls -- either from the session if a token # was previously created, or has expired, or directly from FOLIO otherwise. + # + # TODO: Caching is being disabled for now, since it's causing problems with the new expiring + # token mechanism in FOLIO. We need to figure out how to cache the token properly. (mjc12) def folio_token - if session[:folio_token].nil? || (session[:folio_token_exp].present? && Time.now > Time.parse(session[:folio_token_exp])) + # if session[:folio_token].nil? || (session[:folio_token_exp].present? && Time.now > Time.parse(session[:folio_token_exp])) url = ENV['OKAPI_URL'] tenant = ENV['OKAPI_TENANT'] response = CUL::FOLIO::Edge.authenticate(url, tenant, ENV['OKAPI_USER'], ENV['OKAPI_PW']) @@ -74,7 +77,7 @@ def folio_token session[:folio_token] = response[:token] session[:folio_token_exp] = response[:token_exp] end - end + # end session[:folio_token] end diff --git a/lib/my_account/version.rb b/lib/my_account/version.rb index abeebc5..17272ab 100644 --- a/lib/my_account/version.rb +++ b/lib/my_account/version.rb @@ -1,3 +1,3 @@ module MyAccount - VERSION = '2.3.1' + VERSION = '2.3.2' end diff --git a/release_notes.md b/release_notes.md index 43502a9..12d7c01 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,10 @@ # Release Notes - my-account +## [2.3.2] - 2024-08-26 + +### Fixed +- New FOLIO token auth scheme causing problems because of token caching; caching disabled for now + ## [2.3.1] - 2024-08-20 ### Fixed From f679f7421a728d7befb57bb39fcdec2f52617a08 Mon Sep 17 00:00:00 2001 From: Melissa Wallace Date: Tue, 17 Sep 2024 09:47:24 -0400 Subject: [PATCH 4/5] DACCESS-375: update links to fine information --- app/views/my_account/account/_fines.html.haml | 2 +- app/views/my_account/account/intro.html.haml | 5 +++-- release_notes.md | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/my_account/account/_fines.html.haml b/app/views/my_account/account/_fines.html.haml index c0f4a1f..815b24a 100644 --- a/app/views/my_account/account/_fines.html.haml +++ b/app/views/my_account/account/_fines.html.haml @@ -21,4 +21,4 @@ %td = number_to_currency(f['chargeAmount']['amount']) %p -= link_to "View fine rates", "https://catalog.library.cornell.edu/myaccount/login" \ No newline at end of file += link_to "View fine rates", "https://www.library.cornell.edu/collections/borrow-renew-return/policies/#fines" \ No newline at end of file diff --git a/app/views/my_account/account/intro.html.haml b/app/views/my_account/account/intro.html.haml index 6ff8450..e5900cb 100644 --- a/app/views/my_account/account/intro.html.haml +++ b/app/views/my_account/account/intro.html.haml @@ -12,6 +12,7 @@ =link_to('libpublicservices@cornell.edu', 'mailto:libpublicservices@cornell.edu') \. -%h3 Library fines %p - The fine for recalled items is $3.00/day for every patron category. If unreturned, high cost and high demand items (such as laptops, equipment, reserves items) will be billed for replacement cost after two days. Regular items (such as books from the general circulating collection) will be billed for replacement cost after 27 days. When the billed amount reaches $300 for Cornell patrons (or $150 for others), the borrower’s access to the Library will be blocked until the item is returned. \ No newline at end of file + Visit the library website for + =link_to('fine information', 'https://www.library.cornell.edu/collections/borrow-renew-return/policies/#fines') + \. \ No newline at end of file diff --git a/release_notes.md b/release_notes.md index 12d7c01..ccfa6f7 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,8 @@ # Release Notes - my-account +## [2.3.3] - 2024-09-17 +- Update links to fine information + ## [2.3.2] - 2024-08-26 ### Fixed From 1a53cc8fd3c548fe00d4d36f5a838c7148465584 Mon Sep 17 00:00:00 2001 From: Melissa Wallace Date: Tue, 17 Sep 2024 13:03:08 -0400 Subject: [PATCH 5/5] Update version.rb --- lib/my_account/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/my_account/version.rb b/lib/my_account/version.rb index 17272ab..74db2c3 100644 --- a/lib/my_account/version.rb +++ b/lib/my_account/version.rb @@ -1,3 +1,3 @@ module MyAccount - VERSION = '2.3.2' + VERSION = '2.3.3' end