Skip to content

Commit

Permalink
Merge pull request #2123 from sul-dlss/hoooover
Browse files Browse the repository at this point in the history
Adds support for updated Hoover Archive requests
  • Loading branch information
Jessie Keck committed Nov 8, 2018
2 parents 183dfdc + 1704422 commit 018be42
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Changed
- Now returning a 404 Not Found error when an article record is not found [#2133](https://github.com/sul-dlss/SearchWorks/pull/2133)
- Updates the way that Hoover Archive records are requested and shown in the access panel [#2123](https://github.com/sul-dlss/SearchWorks/pull/2123)
### Removed
### Fixed
- Updated the EBSCO gem to 1.0.5 to address issues around records throwing errors when trying to sanitize HTML [#1704](https://github.com/sul-dlss/SearchWorks/issues/1704)
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/modules/availability-icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ $noncirc-color: darkorange;
@extend .fa-truck;
color: $noncirc-color;
}
.unavailable {
.unavailable,
.in_process {
@extend .fa-times;
color: #990000;
}
Expand Down
10 changes: 9 additions & 1 deletion app/views/catalog/access_panels/_location.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
<%= content_tag(:div, class: 'bound-with-note note-highlight') { render document.bound_with_note } %>
<% else %>
<% if location_level_request_link?(library, location) %>
<%= link_to_request_link(document: document, library: library, callnumber: location.items.first, class: 'btn btn-default btn-xs request-button pull-right') %>
<% if library.hoover_archive? %>
<% if document.index_links.finding_aid.present? %>
<%= link_to 'Request via Finding Aid', document.index_links.finding_aid.first.href, class: 'btn btn-default btn-xs request-button pull-right' %>
<% else %>
<div class='pull-right'>Not available to request</div>
<% end %>
<% else %>
<%= link_to_request_link(document: document, library: library, callnumber: location.items.first, class: 'btn btn-default btn-xs request-button pull-right') %>
<% end %>
<% end %>
<% end %>
<% if location.mhld.present? %>
Expand Down
11 changes: 6 additions & 5 deletions lib/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ module Constants
'unavailable' => 'Unavailable',
'noncirc' => 'In-library use',
'unknown' => 'Unknown',
'noncirc_page' => 'In-library use'
'noncirc_page' => 'In-library use',
'in_process' => 'In process'
}
HIDE_1ST_IND = %w(760 762 765 767 770 772 773 774 775 776 777 780 785 786 787)
HIDE_1ST_IND0 = %w(541 542 561 583 590)
Expand Down Expand Up @@ -1249,12 +1250,12 @@ module Constants

LIBRARY_INSTRUCTIONS = {
'HOOVER' => {
heading: 'All items must be requested in advance',
text: 'Stanford ID holders may be able to check out some monographs marked "Available" next to the call number. "In-library use" call numbers are for reading-room use only.'
heading: 'Access',
text: 'Items must be requested in advance and viewed on-site.'
},
'HV-ARCHIVE' => {
heading: 'All items must be viewed on site',
text: "If there's a finding aid shown above, use the Online Archive of California link to request items. Otherwise, use the Request on-site access button below."
heading: 'Access',
text: 'Items must be requested in advance and viewed on-site.'
},
'RUMSEYMAP' => {
heading: 'All items must be viewed on site',
Expand Down
1 change: 1 addition & 0 deletions lib/holdings.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'holdings/append_mhld'
require 'holdings/callnumber'
require 'holdings/in_process'
require 'holdings/library'
require 'holdings/location'
require 'holdings/mhld'
Expand Down
23 changes: 23 additions & 0 deletions lib/holdings/in_process.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Holdings
class Status
##
# Representing libraries that are in process
class InProcess
LIBRARIES = ['HV-ARCHIVE'].freeze

def initialize(callnumber)
@callnumber = callnumber
end

def in_process?
library_in_process?
end

private

def library_in_process?
LIBRARIES.include?(@callnumber.library)
end
end
end
end
4 changes: 4 additions & 0 deletions lib/holdings/library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def zombie?
@code == 'ZOMBIE'
end

def hoover_archive?
@code == 'HV-ARCHIVE'
end

def present?
@items.any?(&:present?) ||
(mhld.present? && mhld.any?(&:present?)) ||
Expand Down
6 changes: 6 additions & 0 deletions lib/holdings/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def initialize(callnumber)

def availability_class
case
when in_process?
'in_process'
when unavailable?
'unavailable'
when noncirc_page?
Expand Down Expand Up @@ -59,6 +61,10 @@ def unknown?
Holdings::Status::Unknown.new(@callnumber).unknown?
end

def in_process?
Holdings::Status::InProcess.new(@callnumber).in_process?
end

def as_json(*)
{ availability_class: availability_class, status_text: status_text }
end
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/holdings/in_process_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

describe Holdings::Status::InProcess do
describe 'in_process libraries' do
let(:in_process_libraries) { %w[HV-ARCHIVE] }

it 'should identify any items as in_process' do
in_process_libraries.each do |library|
expect(Holdings::Status::InProcess.new(OpenStruct.new(library: library))).to be_in_process
end
end
end
end
6 changes: 6 additions & 0 deletions spec/lib/holdings/library_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
expect(zombie).to_not be_holding_library
end
end
describe '#hoover_archive?' do
let(:hv_archive) { Holdings::Library.new('HV-ARCHIVE') }
it 'is true' do
expect(hv_archive.hoover_archive?).to be true
end
end
describe "#mhld" do
let(:library) {Holdings::Library.new("GREEN")}
it "should be an accessible attribute" do
Expand Down
35 changes: 35 additions & 0 deletions spec/views/catalog/access_panels/_location.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,39 @@
expect(rendered).to have_css('p', text: 'Request items at least 2 days before you visit to allow retrieval from off-site storage. You can request at most 5 items per day.')
end
end
describe 'Hoover Archives' do
context 'when a finding aid is present' do
before do
assign(
:document,
SolrDocument.new(
id: '123',
item_display: ['123 -|- HV-ARCHIVE -|- STACKS -|- -|- -|- -|- -|- -|- ABC -|-'],
url_suppl: ['http://oac.cdlib.org/findaid/ark:/something-else']
)
)
render
end
it 'renders request via OAC finding aid' do
expect(rendered).to have_css 'a[href*="oac"]', text: 'Request via Finding Aid'
end
end
context 'without a finding aid' do
before do
assign(
:document,
SolrDocument.new(
id: '123',
item_display: ['123 -|- HV-ARCHIVE -|- STACKS -|- -|- -|- -|- -|- -|- ABC -|-']
)
)
render
end
it 'renders not available text' do
expect(rendered).to have_css '.panel-body .pull-right', text: 'Not available to request'
expect(rendered).to have_css '.availability-icon.in_process'
expect(rendered).to have_css '.status-text', text: 'In process'
end
end
end
end

0 comments on commit 018be42

Please sign in to comment.