Skip to content

Commit

Permalink
Merge pull request #29 from cul-it/dev
Browse files Browse the repository at this point in the history
Merge 1.2.2 changes from dev to master
  • Loading branch information
Baroquem committed Apr 18, 2016
2 parents 17cbffe + 694a3e8 commit 2b84d63
Show file tree
Hide file tree
Showing 19 changed files with 396 additions and 204 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ spec/dummy/tmp/
spec/dummy/.sass-cache
tmp
Gemfile.lock
.env
.env
.yardoc
27 changes: 16 additions & 11 deletions app/controllers/blacklight_cornell_requests/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@ def magic_request target=''
@id = params[:bibid]
resp, @document = get_solr_response_for_doc_id(@id)
@document = @document



Rails.logger.debug "Viewing item #{@id} (within request controller) - session: #{session}"

req = BlacklightCornellRequests::Request.new(@id)
req.netid = request.env['REMOTE_USER']
req.netid = request.env['REMOTE_USER']
req.netid.sub!('@CORNELL.EDU', '') unless req.netid.nil?


# When we're entering the request system from a /catalog path, then we're starting
# fresh — no volume should be pre-selected (or kept in the session). However,
# if the referer is a different path — i.e., /request/*, then we *do* want to
# preserve the volume selection; this would be the case if the page is reloaded
# or the user selects an alternate delivery method for the same item.
session[:volume] = nil if request.referer.include? 'catalog'

params[:volume] = session[:volume]
# Reset session var after use so that we don't get weird results if
# user goes to another catalog item
session[:volume] = nil
session[:volume] = nil

req.magic_request @document, request.env['HTTP_HOST'], {:target => target, :volume => params[:volume]}

if ! req.service.nil?
Expand All @@ -40,7 +45,7 @@ def magic_request target=''
@au = req.au
@isbn = req.isbn
@ill_link = req.ill_link
@pub_info = req.pub_info
@pub_info = req.pub_info
@volume = params[:volume]
@netid = req.netid
@name = get_patron_name req.netid
Expand All @@ -56,7 +61,7 @@ def magic_request target=''
# @volumes = req.set_volumes(req.all_items)
@volumes = req.volumes
# Note: the if statement here only shows the volume select screen
# if a doc del request has *not* been specified. This is because
# if a doc del request has *not* been specified. This is because
# (a) without that statement, the user just loops endlessly through
# volume selection and doc del requesting; and (b) since we can't
# pre-populate the doc del request form with bibliographic data, there's
Expand Down Expand Up @@ -86,7 +91,7 @@ def magic_request target=''
@alternate_request_options.push({:option => option[:service], :estimate => option[:estimate]})
end
end

@counter = params[:counter]
if @counter.blank? and session[:search].present?
@counter = session[:search][:counter]
Expand Down Expand Up @@ -156,7 +161,7 @@ def make_voyager_request
if params[:library_id].blank?
errors << I18n.t('requests.errors.library_id.blank')
end

if errors
flash[:error] = errors.join('<br/>').html_safe
end
Expand Down Expand Up @@ -227,7 +232,7 @@ def make_purchase_request
render :partial => '/flash_msg', :layout => false

end

# AJAX responder used with requests.js.coffee to set the volume
# when the user selects one in the volume drop-down list
def set_volume
Expand Down
11 changes: 2 additions & 9 deletions app/models/blacklight_cornell_requests/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def magic_request(document, env_http_host, options = {})

# Check borrow direct availability
bd_params = { :isbn => document[:isbn_display], :title => document[:title_display], :env_http_host => env_http_host }
Rails.logger.debug "es287_log :#{__FILE__}:#{__LINE__} isbn_display=#{document[:isbn_display]} "
Rails.logger.debug "es287_log :#{__FILE__}:#{__LINE__} bd_params=#{bd_params} "
self.in_borrow_direct = available_in_bd? self.netid, bd_params

# Get item status and location for each item in each holdings record; store in working_items
Expand Down Expand Up @@ -135,6 +133,7 @@ def magic_request(document, env_http_host, options = {})

self.items = working_items
self.document = document

#Rails.logger.debug "es287_log :#{__FILE__}:#{__LINE__} working items processed. number of items: #{self.items.size} at"+ Time.new.inspect

unless document.nil?
Expand Down Expand Up @@ -636,7 +635,6 @@ def get_delivery_options item

# Determine delivery options for a single item if the patron is a Cornell affiliate
def get_cornell_delivery_options item

typeCode = (item[:temp_item_type_id].blank? or item[:temp_item_type_id] == '0') ? item[:item_type_id] : item[:temp_item_type_id]
item_loan_type = loan_type typeCode
request_options = []
Expand Down Expand Up @@ -988,6 +986,7 @@ def available_in_bd? netid, params

# Set up params for BorrowDirect gem
BorrowDirect::Defaults.api_key = ENV['BORROW_DIRECT_TEST_API_KEY']
BorrowDirect::Defaults.api_base = 'https://bdtest.relais-host.com/'
BorrowDirect::Defaults.library_symbol = 'CORNELL'
BorrowDirect::Defaults.find_item_patron_barcode = patron_barcode(netid)
BorrowDirect::Defaults.timeout = 30 # (seconds)
Expand All @@ -1003,7 +1002,6 @@ def available_in_bd? netid, params
if !params[:isbn].nil?
# Note: [*<variable>] gives us an array if we don't already have one,
# which we need for the map.

response = BorrowDirect::FindItem.new.find(:isbn => ([*params[:isbn]].map!{|i| i = i.clean_isbn}))
elsif !params[:title].nil?
response = BorrowDirect::FindItem.new.find(:phrase => params[:title])
Expand Down Expand Up @@ -1060,10 +1058,6 @@ def patron_barcode(netid)
end
end

#class String
#def clean_isbn
# return self.gsub! /[^0-9X]*/, ''
#end
class String
def clean_isbn
temp = self
Expand All @@ -1077,4 +1071,3 @@ def clean_isbn
end



11 changes: 5 additions & 6 deletions app/views/blacklight_cornell_requests/request/bd.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
%p
Delivery time:
= delivery_estimate_display @estimate
.control-group
.controls.clearfix
- if @isbn.present?
= link_to 'Search Borrow Direct', borrowdirect_url_from_isbn(@isbn), :class => 'btn btn-danger pull-left'
- else
= link_to 'Search Borrow Direct', borrowdirect_url_from_title(@ti), :class => 'btn btn-danger pull-left'
.form-group
- if @isbn.present?
= link_to 'Search Borrow Direct', borrowdirect_url_from_isbn(@isbn), :class => 'btn btn-danger pull-left'
- else
= link_to 'Search Borrow Direct', borrowdirect_url_from_title(@ti), :class => 'btn btn-danger pull-left'

-if @alternate_request_options and @alternate_request_options.count >= 2
= render :partial => 'shared/request_options'
Expand Down
37 changes: 17 additions & 20 deletions app/views/blacklight_cornell_requests/request/hold.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,40 @@
- user = request.env['REMOTE_USER'].inspect
= "Request a hold for " + user
%div.row
%div.span8.well
%div.well
%h2.item-title-request.blacklight-title_display=title
%div.request-author=responsibility
%form#req.form-horizontal{:method => 'post', :action => make_voyager_request_path}
-if @volumes.present? && @volumes.count > 1
.control-group
%label.control-label{:for => "volume-selection"}
.form-group
%label.control-label.col-sm-2{:for => "volume-selection"}
Current Volume:
.controls.delivery-estimate
.col-sm-10.delivery-estimate
= render :partial =>'shared/volume_select'
%input(type="hidden" name="bid" value="#{@id}" id="bid")
%input(type="hidden" name="request_action" value="hold" id="request_action")
= render :partial => 'shared/reqac'
= render :partial => 'shared/reqpu'
.control-group
%label.control-label{:for => 'reqcomments'} Notes to library staff:
.controls
.form-group
%label.control-label.col-sm-2{:for => 'reqcomments'} Notes to library staff:
.col-sm-10
%textarea(name="reqcomments" id="reqcomments" class="form-control")
= render :partial => 'shared/request_date'
- if !@estimate.blank?
.control-group
%label.control-label Delivery time:
.controls.delivery-estimate
.form-group
%label.control-label.col-sm-2 Delivery time:
.col-sm-10.delivery-estimate
Approximately
= delivery_estimate_display @estimate
-if @alternate_request_options and @alternate_request_options.count >= 2
.control-group
.controls.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit hold request")
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit hold request")
= render :partial => 'shared/request_options'
-else
.control-group
.controls.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit hold request")
%div.accordion-heading.request-options.pull-left.form-alternative-action
or
=link_to 'Ask a Librarian','http://ask.library.cornell.edu'
for help.
%div.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit hold request")
%div.accordion-heading.request-options.pull-left.form-alternative-action
or
=link_to 'Ask a Librarian','http://ask.library.cornell.edu'
for help.
-## Used to display working status and result of request via Ajax
#result
39 changes: 18 additions & 21 deletions app/views/blacklight_cornell_requests/request/l2l.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,41 @@
%h1.request-type
= "Request Cornell library to library delivery for user: " + request.env['REMOTE_USER'].inspect
%div.row
%div.span8.well
%div.well
%h2.blacklight-title_display.item-title-request
=title
%div.request-author=responsibility
%form#req.l2l-request.form-horizontal{:method => 'post', :action => make_voyager_request_path({:bibid =>@id})}
-if @volumes.present? && @volumes.count > 1
.control-group
%label.control-label{:for => "volume-selection"}
Current Volume:
.controls.delivery-estimate
.form-group
%label.control-label.col-sm-2{:for => "volume-selection"}
Current volume:
.delivery-estimate.col-sm-10
= render :partial =>'shared/volume_select'
%input(type="hidden" name="bid" value="#{@id}" id="bid")
%input(type="hidden" name="request_action" value="callslip" id="request_action")
= render :partial => 'shared/l2lac'
= render :partial => 'shared/reqpu'
.control-group
%label.control-label{:for => 'reqcomments'} Notes to library staff:
.controls
.form-group
%label.control-label.col-sm-2{:for => 'reqcomments'} Notes to library staff:
.col-sm-10
%textarea(name="reqcomments" id="reqcomments" class="form-control")
- if !@estimate.blank?
.control-group
%label.control-label Delivery time:
.controls.delivery-estimate
.form-group
%label.control-label.col-sm-2 Delivery time:
.delivery-estimate.col-sm-10
Approximately
= delivery_estimate_display @estimate
-if @alternate_request_options and @alternate_request_options.count >= 2
.control-group
.controls.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit delivery request")
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit delivery request")
= render :partial => 'shared/request_options'
-else
.control-group
.controls.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit delivery request")
%div.accordion-heading.request-options.pull-left.form-alternative-action
or
=link_to 'Ask a Librarian','http://ask.library.cornell.edu'
for help.
%div.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit delivery request")
%div.accordion-heading.request-options.pull-left.form-alternative-action
or
=link_to 'Ask a Librarian','http://ask.library.cornell.edu'
for help.

-## Used to display working status and result of request via Ajax
#result
Loading

0 comments on commit 2b84d63

Please sign in to comment.