• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.82
/app/controllers/account_controller.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client.rb'
1✔
3
require './lib/orangelight/illiad_account.rb'
1✔
4

5
class AccountController < ApplicationController
1✔
6
  include ApplicationHelper
1✔
7

8
  before_action :read_only_redirect, except: [:user_id]
1✔
9
  before_action :check_for_authentication_provider, except: [:user_id]
1✔
10
  before_action :verify_user, except: [:user_id]
1✔
11

12
  def index
1✔
13
    redirect_to digitization_requests_path
×
14
  end
15

16
  def digitization_requests
1✔
17
    set_patron
×
18
  end
19

20
  def cancel_ill_requests
1✔
21
    set_patron
×
22
    response = Orangelight::IlliadPatronClient.new(@patron).cancel_ill_requests(params[:cancel_requests]) unless params[:cancel_requests].nil?
×
23
    illiad_patron_client(@patron)
×
24
    respond_to do |format|
×
25
      if params[:cancel_requests].nil?
×
26
        format.js { flash.now[:error] = I18n.t('blacklight.account.cancel_no_items') }
×
27
      elsif cancel_ill_success?(response)
×
28
        format.js { flash.now[:success] = I18n.t('blacklight.account.cancel_success') }
×
29
      else
30
        format.js { flash.now[:error] = I18n.t('blacklight.account.cancel_fail') }
×
31
      end
32
    end
33
  end
34

35
  def user_id
1✔
36
    render json: { user_id: current_user&.uid }
×
37
  end
38

39
  protected
1✔
40

41
    def read_only_redirect
1✔
42
      if Orangelight.read_only_mode
×
43
        flash[:notice] = 'Account login unavailable during maintenace.'
×
44
        redirect_to(root_url) && return
×
45
      end
46
    end
47

48
    def check_for_authentication_provider
1✔
49
      raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
×
50
    end
51

52
    def verify_user
1✔
53
      unless current_user
×
54
        flash[:error] = I18n.t('blacklight.saved_searches.need_login') &&
×
55
                        raise(Blacklight::Exceptions::AccessDenied)
56
      end
57
    end
58

59
    ## For local dev purposes hardcode a net id string in place of current_user.uid
60
    ## in this method. Hacky, but convienent to see what "real" data looks like for
61
    ## edge case patrons.
62
    def set_patron
1✔
63
      @netid = current_user.uid
×
64
      @patron = current_patron(current_user)
×
65
      illiad_patron_client(@patron)
×
66
    end
67

68
    def illiad_patron_client(patron)
1✔
69
      @illiad_transactions = []
×
70
      return unless patron && current_user.cas_provider?
×
71

72
      @illiad_account = Orangelight::IlliadAccount.new(patron)
×
73
      return unless @illiad_account.verify_user?
×
74

75
      @illiad_transactions = Orangelight::IlliadPatronClient.new(patron).outstanding_ill_requests
×
76
    end
77

78
    def cancel_ill_success?(response)
1✔
79
      bodies = response.map { |rep| JSON.parse(rep.body) }
×
80
      bodies.reject { |body| body['TransactionStatus'] =~ /^Cancelled/ }.empty?
×
81
    end
82

83
  private
1✔
84

85
    def current_patron(user)
1✔
86
      Bibdata.get_patron(user, ldap: false)
×
87
    end
88
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc