Skip to content

Commit

Permalink
Merge pull request #25 from cul-it/dev
Browse files Browse the repository at this point in the history
Merge dev changes for v1.2 release
  • Loading branch information
Baroquem committed Nov 17, 2015
2 parents 9c562d6 + 90a2965 commit 98df42d
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 218 deletions.
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ gem "thor"
#gem 'blacklight', '5.9'
gem 'rails', '~>4.0'

# NOTE: BD should really be specified in the gemspec, but we need a specific
# git repo branch for now, so we have to make the call here. Once we're back
# on master, we should be able to remove this call and uncomment the one in
# the gemspec file
gem 'borrow_direct', :git => 'git@github.com:jrochkind/borrow_direct.git'

gemspec

# jquery-rails is used by the dummy application
Expand Down
22 changes: 17 additions & 5 deletions app/models/blacklight_cornell_requests/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -985,21 +985,23 @@ def make_voyager_request params
def available_in_bd? netid, params

# Set up params for BorrowDirect gem
if Rails.env.production?
# if this isn't specified, defaults to BD test database
#BorrowDirect::Defaults.api_base = BorrowDirect::Defaults::PRODUCTION_API_BASE
end
BorrowDirect::Defaults.api_key = ENV['BORROW_DIRECT_TEST_API_KEY']
BorrowDirect::Defaults.library_symbol = 'CORNELL'
BorrowDirect::Defaults.api_key = ENV['BORROW_DIRECT_API_KEY']
BorrowDirect::Defaults.find_item_patron_barcode = patron_barcode(netid)
BorrowDirect::Defaults.timeout = 30 # (seconds)
# if api_base isn't specified, it defaults to BD test database
if Rails.env.production?
BorrowDirect::Defaults.api_base = BorrowDirect::Defaults::PRODUCTION_API_BASE
BorrowDirect::Defaults.api_key = ENV['BORROW_DIRECT_PROD_API_KEY']
end

response = nil
# This block can throw timeout errors if BD takes to long to respond
begin
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.clean_isbn}))
elsif !params[:title].nil?
response = BorrowDirect::FindItem.new.find(:phrase => params[:title])
Expand All @@ -1009,16 +1011,25 @@ def available_in_bd? netid, params
return response.requestable?

rescue Errno::ECONNREFUSED => e
if ENV['ROUTE_EXCEPTIONS_TO_HIPCHAT'] == 'true'
ExceptionNotifier.notify_exception(e)
end
Rails.logger.warn 'Requests: Borrow Direct connection was refused'
Rails.logger.warn e.message
Rails.logger.warn e.backtrace.inspect
return false
rescue BorrowDirect::HttpTimeoutError => e
if ENV['ROUTE_EXCEPTIONS_TO_HIPCHAT'] == 'true'
ExceptionNotifier.notify_exception(e)
end
Rails.logger.warn 'Requests: Borrow Direct check timed out'
Rails.logger.warn e.message
Rails.logger.warn e.backtrace.inspect
return false
rescue BorrowDirect::Error => e
if ENV['ROUTE_EXCEPTIONS_TO_HIPCHAT'] == 'true'
ExceptionNotifier.notify_exception(e)
end
Rails.logger.warn 'Requests: Borrow Direct gave error.'
Rails.logger.warn e.message
Rails.logger.warn e.backtrace.inspect
Expand Down Expand Up @@ -1053,3 +1064,4 @@ def clean_isbn
end
end


108 changes: 40 additions & 68 deletions app/views/blacklight_cornell_requests/request/hold.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,47 @@
-responsibility = render_document_show_field_value :document => @document, :field => 'title_responsibility_display'
- @selected_volume = params[:volume]
= render :partial => 'shared/back_to_item'
%h2
%h1.request-type
- user = request.env['REMOTE_USER'].inspect
= "Request a hold for " + user
%div.well
%h3.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
.form-group
%label.control-label.col-sm-2{:for => "volume-selection"}
Current Volume:
.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'
.form-group
%label.control-label.col-sm-2{:for => 'reqcomments'} Notes to library staff:
.col-sm-6
%textarea#reqcomments.form-control{:name => 'reqcomments'}
= render :partial => 'shared/request_date'
- if !@estimate.blank?
.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
.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit hold request")
= render :partial => 'shared/request_options'
-else
.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.row
%div.span8.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"}
Current Volume:
.controls.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
%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
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")
= 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.
-## Used to display working status and result of request via Ajax
#result



/ <form class="form-horizontal">
/ <div class="form-group">
/ <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
/ <div class="col-sm-10">
/ <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
/ </div>
/ </div>
/ <div class="form-group">
/ <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
/ <div class="col-sm-10">
/ <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
/ </div>
/ </div>
/ <div class="form-group">
/ <div class="col-sm-offset-2 col-sm-10">
/ <div class="checkbox">
/ <label>
/ <input type="checkbox"> Remember me
/ </label>
/ </div>
/ </div>
/ </div>
/ <div class="form-group">
/ <div class="col-sm-offset-2 col-sm-10">
/ <button type="submit" class="btn btn-default">Sign in</button>
/ </div>
/ </div>
/ </form>
77 changes: 40 additions & 37 deletions app/views/blacklight_cornell_requests/request/l2l.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,47 @@
-responsibility = render_document_show_field_value :document => @document, :field => 'title_responsibility_display'
- @selected_volume = params[:volume]
= render :partial => 'shared/back_to_item'
%h2
%h1.request-type
= "Request Cornell library to library delivery for user: " + request.env['REMOTE_USER'].inspect
%div.well
%h3.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
.form-group
%label.control-label.col-sm-2{:for => "volume-selection"}
Current Volume:
.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="callslip" id="request_action")
= render :partial => 'shared/l2lac'
= render :partial => 'shared/reqpu'
.form-group
%label.control-label.col-sm-2{:for => 'reqcomments'} Notes to library staff:
.col-sm-6
%textarea#reqcomments.form-control
- if !@estimate.blank?
.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
.clearfix
%input#request-submit.btn.btn-danger.pull-left(type="submit" name="submit" value="Submit delivery request")
= render :partial => 'shared/request_options'
-else
.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.row
%div.span8.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
= 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
%textarea(name="reqcomments" id="reqcomments" class="form-control")
- if !@estimate.blank?
.control-group
%label.control-label Delivery time:
.controls.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 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.

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

0 comments on commit 98df42d

Please sign in to comment.