Skip to content

Commit

Permalink
Merge pull request #82 from cul-it/dev
Browse files Browse the repository at this point in the history
Merge dev for v1.3.1
  • Loading branch information
Baroquem authored Oct 24, 2016
2 parents e75669b + c4cfa5f commit f351b2b
Show file tree
Hide file tree
Showing 17 changed files with 290 additions and 259 deletions.
33 changes: 21 additions & 12 deletions app/controllers/blacklight_cornell_requests/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ def initialize(data)
@data = data
end
end

class RequestController < ApplicationController

include Blacklight::SolrHelper
include Blacklight::Catalog # needed for "fetch", replaces "include SolrHelper"
include Cornell::LDAP


# This may seem redundant, but it makes it easier to fetch the document from
# various model classes
def get_solr_doc doc_id
resp, document = fetch doc_id
document
end

def magic_request target=''

@id = params[:bibid]
resp, @document = get_solr_response_for_doc_id(@id)
resp, @document = fetch @id
@document = @document

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

# Do a check to see whether the circ_policy_locs table is populated — for some
# bizarre reason, it has been turning up empty in production.
# bizarre reason, it has been turning up empty in production.
begin
if Circ_policy_locs.count() < 1
raise BlacklightCornellRequests::RequestDatabaseException, 'circ_policy_locs table has less than one row'
Expand All @@ -35,15 +42,15 @@ def magic_request target=''
Appsignal.add_exception(e)
end

# If the holdings data has been stored in the session (:holdings_status_short),
# If the holdings data has been stored in the session (:holdings_status_short),
# we'll pass it in to the request to be reused instead of making
# the expensive holdings service call again. As soon as it's used, the session
# data gets cleared so that we don't end up passing stale session data for a different
# bibid into the request next time (if someone manipulates the URL instead of following
# the normal catalog path). A better way of handling this might be to compare the
# bibid and the key of the holdings data, which should be the same.
session_holdings = session[:holdings_status_short]
session[:holdings_status_short] = nil
session[:holdings_status_short] = nil
req = BlacklightCornellRequests::Request.new(@id, session_holdings)
req.netid = request.env['REMOTE_USER']
req.netid.sub!('@CORNELL.EDU', '') unless req.netid.nil?
Expand All @@ -54,20 +61,20 @@ def magic_request target=''
# 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.
if session[:setvol].nil? && (request.referer && request.referer.include?('catalog'))
session[:volume] = nil
session[:volume] = nil
end
session[:setvol] = nil

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

# If there's a URL-based volume present, that overrides the session data (this
# should only happen now if someone is linking into requests from outside the main
# catalog).
if params[:enum] || params[:chron] || params[:year]
params[:volume] = "|#{params[:enum]}|#{params[:chron]}|#{params[:year]}|"
params[:volume] = "|#{params[:enum]}|#{params[:chron]}|#{params[:year]}|"
end

req.magic_request @document, request.env['HTTP_HOST'], {:target => target, :volume => params[:volume]}
Expand Down Expand Up @@ -112,7 +119,9 @@ def magic_request target=''
else
# a bit hacky solution here to get to request path
# will need more rails compliant solution down the road...
redirect_to '/request' + request.env['PATH_INFO'] + "/#{req.volumes[req.volumes.keys[0]]}"
# modified to use new volume specification schema
enum, chron, year = req.volumes[req.volumes.keys[0]][1..-1].split /\|/
redirect_to '/request' + request.env['PATH_INFO'] + "?enum=#{enum}&chron=#{chron}&year=#{year}" #{}"/#{req.volumes[req.volumes.keys[0]]}"
return
end
elsif req.request_options.present?
Expand Down Expand Up @@ -226,7 +235,7 @@ def make_voyager_request
if response[:failure].blank?
# Note: the :flash=>'success' in this case is not setting the actual flash message,
# but instead specifying a URL parameter that acts as a flag in Blacklight's show.html.erb view.
render js: "window.location = '#{Rails.application.routes.url_helpers.catalog_path(params[:bibid], :flash=>'success')}'"
render js: "window.location = '#{Rails.application.routes.url_helpers.solr_document_path(params[:bibid], :flash=>'success')}'"
return
else
Rails.logger.info "Response: was failure" + response[:failure].inspect
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/blacklight_cornell_requests/request_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def delivery_estimate_display time_estimate
end

end

end
end
2 changes: 1 addition & 1 deletion app/models/blacklight_cornell_requests/delivery_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class DocumentDelivery < DeliveryMethod
TemplateName = 'document_delivery'

def self.description
'Document Delivery'
'ScanIt'
end

def self.time(options = {})
Expand Down
Loading

0 comments on commit f351b2b

Please sign in to comment.