• 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

99.17
/app/models/requests/requestable.rb
1
# frozen_string_literal: true
2
module Requests
1✔
3
  # This class describes a resource that a
4
  # library patron might wish to request
5
  class Requestable
1✔
6
    attr_reader :bib
1✔
7
    attr_reader :holding
1✔
8
    attr_reader :item
1✔
9
    attr_reader :location
1✔
10
    attr_reader :call_number
1✔
11
    attr_reader :title
1✔
12
    attr_reader :patron
1✔
13
    attr_reader :services
1✔
14

15
    delegate :illiad_request_url, :illiad_request_parameters, to: :@illiad
1✔
16
    delegate :eligible_for_library_services?, to: :@patron
1✔
17

18
    include Requests::Aeon
1✔
19

20
    # @param bib [Hash] Solr Document of the Top level Request
21
    # @param holding [Requests::Holding] Bibdata information on where the item is held, created with data from the parsed solr_document[holdings_1display] json
22
    # @param item [Hash] Item level data from bib data (https://bibdata.princeton.edu/availability?id= or mfhd=)
23
    # @param location [Hash] The hash for a bib data holding (https://bibdata.princeton.edu/locations/holding_locations)
24
    # @param patron [Patron] the patron information about the current user
25
    def initialize(bib:, holding: nil, item: nil, location: nil, patron:)
1✔
26
      @bib = bib
2,265✔
27
      @holding = holding
2,265✔
28
      # Item inherits from SimpleDelegator which requires at least one argument
29
      # The argument is the Object that SimpleDelegator will delegate to.
30
      @item = item.present? ? Item.new(item) : NullItem.new({})
2,265✔
31
      @location = location
2,265✔
32
      @services = []
2,265✔
33
      @patron = patron
2,265✔
34
      @call_number = @holding.holding_data['call_number_browse']
2,265✔
35
      @title = bib[:title_citation_display]&.first
2,265✔
36
      @illiad = Requests::Illiad.new(enum: item&.fetch(:enum, nil), chron: item&.fetch(:chron, nil), call_number:)
2,265✔
37
    end
38

39
    delegate :pick_up_location_code, :item_type, :enum_value, :cron_value, :item_data?,
1✔
40
             :temp_loc_other_than_resource_sharing?, :on_reserve?, :enumerated?, :item_type_non_circulate?, :partner_holding?,
41
             :id, :use_statement, :collection_code, :charged?, :status, :status_label, :barcode?, :barcode, :preservation_conservation?, to: :item
42

43
    delegate :annex?, :location_label, to: :location_object
1✔
44

45
    delegate :thesis?, to: :@holding
1✔
46

47
    delegate :numismatics?, to: :@holding
1✔
48

49
    # Reading Room Request
50
    def aeon?
1✔
51
      location_object.aeon? || (use_statement == 'Supervised Use')
19,735✔
52
    end
53

54
    def recap?
1✔
55
      return false unless location_valid?
24,763✔
56
      location_object.recap?
24,763✔
57
    end
58

59
    def recap_pf?
1✔
60
      return false unless recap?
6,106✔
61
      location_object.code == "firestone$pf"
1,224✔
62
    end
63

64
    def clancy_available?
1✔
65
      item_at_clancy? && clancy_item.available?
263✔
66
    end
67

68
    def recap_edd?
1✔
69
      return location[:recap_electronic_delivery_location] == true unless partner_holding?
799✔
70
      in_scsb_edd_collection? && !scsb_in_library_use?
85✔
71
    end
72

73
    def preservation?
1✔
74
      location_object.code == 'pres'
120✔
75
    end
76

77
    def circulates?
1✔
78
      item_type_non_circulate? == false && location[:circulates] == true
4,678✔
79
    end
80

81
    def location_code
1✔
82
      location_object.code
2✔
83
    end
84

85
    def always_requestable?
1✔
86
      location[:always_requestable] == true
154✔
87
    end
88

89
    def use_restriction?
1✔
90
      partner_holding? && use_statement.present?
510✔
91
    end
92

93
    def in_process?
1✔
94
      return false if !item? || partner_holding?
9,933✔
95
      in_process_statuses.include?(item[:status_label])
9,677✔
96
    end
97

98
    def on_order?
1✔
99
      return false unless item? && !partner_holding?
8,181✔
100
      item[:status_label] == 'Acquisition'
7,968✔
101
    end
102

103
    def item?
1✔
104
      item.present?
20,705✔
105
    end
106

107
    def pending?
1✔
108
      return false unless location_valid?
134✔
109
      return false unless on_order? || in_process? || preservation?
134✔
110
      location[:library][:code] != 'recap' || location[:holding_library].present?
14✔
111
    end
112

113
    def ill_eligible?
1✔
114
      services.include?('ill')
1,345✔
115
    end
116

117
    def on_shelf?
1✔
118
      services.include?('on_shelf')
549✔
119
    end
120

121
    # assume numeric ids come from alma
122
    def alma_managed?
1✔
123
      bib[:id].to_i.positive?
9,511✔
124
    end
125

126
    def pick_up_locations
1✔
127
      return nil if location[:delivery_locations].empty?
217✔
128
      if partner_holding?
206✔
129
        scsb_pick_up_override(item[:collection_code])
11✔
130
      else
131
        location[:delivery_locations]
195✔
132
      end
133
    end
134

135
    # override the default delivery location for SCSB at certain collection codes
136
    def scsb_pick_up_override(collection_code)
1✔
137
      if ['AR', 'FL'].include? collection_code
11✔
138
        [Requests::BibdataService.delivery_locations[:PJ]]
2✔
139
      elsif collection_code == 'MR'
9✔
140
        [Requests::BibdataService.delivery_locations[:PK]]
3✔
141
      else
142
        location[:delivery_locations]
6✔
143
      end
144
    end
145

146
    def scsb_in_library_use?
1✔
147
      return false unless item?
2,075✔
148
      partner_holding? && (item[:use_statement] == "In Library Use" || collection_code == 'FL')
2,059✔
149
    end
150

151
    def holding_library_in_library_only?
1✔
152
      return false unless location["holding_library"]
760✔
153
      ["marquand", "lewis"].include?(holding_library) || recap_pf?
33✔
154
    end
155

156
    def holding_library
1✔
157
      location_object.holding_library&.dig(:code) || library_code
999✔
158
    end
159

160
    def ask_me?
1✔
161
      services.include?('ask_me')
×
162
    end
163

164
    def item_location_code
1✔
165
      item&.location || location_object.code
515✔
166
    end
167

168
    def held_at_marquand_library?
1✔
169
      library_code == 'marquand' && !recap?
18,987✔
170
    end
171

172
    def marquand_item?
1✔
173
      holding_library == 'marquand'
346✔
174
    end
175

176
    def clancy_item
1✔
177
      @clancy_item ||= Requests::ClancyItem.new(barcode:)
35✔
178
    end
179

180
    def item_at_clancy?
1✔
181
      held_at_marquand_library? && clancy_item.at_clancy?
8,399✔
182
    end
183

184
    def available?
1✔
185
      (always_requestable? && !held_at_marquand_library?) || item.available?
154✔
186
    end
187

188
    def cul_avery?
1✔
189
      item&.collection_code == 'AR'
117✔
190
    end
191

192
    def cul_music?
1✔
193
      item&.collection_code == 'MR'
35✔
194
    end
195

196
    def hl_art?
1✔
197
      item&.collection_code == 'FL'
24✔
198
    end
199

200
    def replace_existing_services(new_services)
1✔
201
      @services = new_services
2,262✔
202
    end
203

204
    private
1✔
205

206
      # Location data presented as an object, rather than a hash.
207
      # The goal is to gradually replace all uses of the hash with
208
      # this object, so that other classes don't need to know the
209
      # exact hash keys to use in order to get the needed data.
210
      def location_object
1✔
211
        @location_object ||= Location.new location
96,589✔
212
      end
213

214
      delegate :library_code, to: :location_object
1✔
215

216
      def in_scsb_edd_collection?
1✔
217
        scsb_edd_collection_codes =
218
          %w[AR BR CA CH CJ CP CR CU EN EV GC GE GS HS JC JD LD LE ML SW UT NA NH NL NP NQ NS NW GN JN JO PA PB PN GP JP] +
85✔
219
          %w[AH DL FL GUT HB HC HJ HK HL HS HW HY MCZ ML TZ WL] # Harvard collections available to digitize
220
        scsb_edd_collection_codes.include?(collection_code)
85✔
221
      end
222

223
      def location_valid?
1✔
224
        location_object.valid?
24,897✔
225
      end
226

227
      def in_process_statuses
1✔
228
        ["Acquisition technical services", "Acquisitions and Cataloging", "In Process"]
9,677✔
229
      end
230
  end
231
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