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

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

0.01 hits per line

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

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

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

18
    include Requests::Aeon
×
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 [Requests::Item] A Requests::Item or similar object (e.g. NullItem)
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:, location: nil, patron:)
×
26
      @bib = bib
×
27
      @holding = holding
×
28
      @item = item
×
29
      @location = location
×
30
      @services = []
×
31
      @patron = patron
×
32
      @call_number = @holding.holding_data['call_number_browse']
×
33
      @title = bib[:title_citation_display]&.first
×
34
      @illiad = Requests::Illiad.new(enum: item&.fetch(:enum, nil), chron: item&.fetch(:chron, nil), call_number:)
×
35
    end
×
36

37
    delegate :pick_up_location_code, :item_type, :enum_value, :cron_value, :item_data?,
×
38
             :temp_loc_other_than_resource_sharing?, :on_reserve?, :enumerated?, :item_type_non_circulate?, :partner_holding?,
×
39
             :id, :use_statement, :collection_code, :charged?, :status, :status_label, :barcode?, :barcode, :preservation_conservation?, to: :item
×
40

41
    delegate :annex?, :location_label, to: :location_object
×
42

43
    delegate :thesis?, to: :@holding
×
44

45
    delegate :numismatics?, to: :@holding
×
46

47
    # Reading Room Request
48
    def aeon?
×
49
      location_object.aeon? || (use_statement == 'Supervised Use')
×
50
    end
×
51

52
    def recap?
×
53
      return false unless location_valid?
×
54
      location_object.recap?
×
55
    end
×
56

57
    def recap_pf?
×
58
      return false unless recap?
×
59
      location_object.code == "firestone$pf"
×
60
    end
×
61

62
    def clancy_available?
×
63
      item_at_clancy? && clancy_item.available?
×
64
    end
×
65

66
    def recap_edd?
×
67
      return location[:recap_electronic_delivery_location] == true unless partner_holding?
×
68
      in_scsb_edd_collection? && !scsb_in_library_use?
×
69
    end
×
70

71
    def preservation?
×
72
      location_object.code == 'pres'
×
73
    end
×
74

75
    def circulates?
×
76
      item_type_non_circulate? == false && location[:circulates] == true
×
77
    end
×
78

79
    def location_code
×
80
      location_object.code
×
81
    end
×
82

83
    def always_requestable?
×
84
      location[:always_requestable] == true
×
85
    end
×
86

87
    def use_restriction?
×
88
      partner_holding? && use_statement.present?
×
89
    end
×
90

91
    def in_process?
×
92
      return false if !item? || partner_holding?
×
93
      in_process_statuses.include?(item[:status_label])
×
94
    end
×
95

96
    def on_order?
×
97
      return false unless item? && !partner_holding?
×
98
      item[:status_label] == 'Acquisition'
×
99
    end
×
100

101
    def item?
×
102
      item.present?
×
103
    end
×
104

105
    def pending?
×
106
      return false unless location_valid?
×
107
      return false unless on_order? || in_process? || preservation?
×
108
      location[:library][:code] != 'recap' || location[:holding_library].present?
×
109
    end
×
110

111
    def ill_eligible?
×
112
      services.include?('ill')
×
113
    end
×
114

115
    def on_shelf?
×
116
      services.include?('on_shelf')
×
117
    end
×
118

119
    # assume numeric ids come from alma
120
    def alma_managed?
×
121
      bib[:id].to_i.positive?
×
122
    end
×
123

124
    def pick_up_locations
×
125
      return nil if location[:delivery_locations].empty?
×
126
      if partner_holding?
×
127
        scsb_pick_up_override(item[:collection_code])
×
128
      else
×
129
        location[:delivery_locations]
×
130
      end
×
131
    end
×
132

133
    # override the default delivery location for SCSB at certain collection codes
134
    def scsb_pick_up_override(collection_code)
×
135
      if ['AR', 'FL'].include? collection_code
×
136
        [Requests::BibdataService.delivery_locations[:PJ]]
×
137
      elsif collection_code == 'MR'
×
138
        [Requests::BibdataService.delivery_locations[:PK]]
×
139
      else
×
140
        location[:delivery_locations]
×
141
      end
×
142
    end
×
143

144
    def scsb_in_library_use?
×
145
      return false unless item?
×
146
      partner_holding? && (item[:use_statement] == "In Library Use" || collection_code == 'FL')
×
147
    end
×
148

149
    def holding_library_in_library_only?
×
150
      return false unless location["holding_library"]
×
151
      ["marquand", "lewis"].include?(holding_library) || recap_pf?
×
152
    end
×
153

154
    def holding_library
×
155
      location_object.holding_library&.dig(:code) || library_code
×
156
    end
×
157

158
    def ask_me?
×
159
      services.include?('ask_me')
×
160
    end
×
161

162
    def item_location_code
×
163
      item&.location || location_object.code
×
164
    end
×
165

166
    def held_at_marquand_library?
×
167
      library_code == 'marquand' && !recap?
×
168
    end
×
169

170
    def marquand_item?
×
171
      holding_library == 'marquand'
×
172
    end
×
173

174
    def clancy_item
×
175
      @clancy_item ||= Requests::ClancyItem.new(barcode:)
×
176
    end
×
177

178
    def item_at_clancy?
×
179
      held_at_marquand_library? && clancy_item.at_clancy?
×
180
    end
×
181

182
    def available?
×
183
      (always_requestable? && !held_at_marquand_library?) || item.available?
×
184
    end
×
185

186
    def cul_avery?
×
187
      item&.collection_code == 'AR'
×
188
    end
×
189

190
    def cul_music?
×
191
      item&.collection_code == 'MR'
×
192
    end
×
193

194
    def hl_art?
×
195
      item&.collection_code == 'FL'
×
196
    end
×
197

198
    def replace_existing_services(new_services)
×
199
      @services = new_services
×
200
    end
×
201

202
    private
×
203

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

212
      delegate :library_code, to: :location_object
×
213

214
      def in_scsb_edd_collection?
×
215
        scsb_edd_collection_codes =
×
216
          %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] +
×
217
          %w[AH DL FL GUT HB HC HJ HK HL HS HW HY MCZ ML TZ WL] # Harvard collections available to digitize
×
218
        scsb_edd_collection_codes.include?(collection_code)
×
219
      end
×
220

221
      def location_valid?
×
222
        location_object.valid?
×
223
      end
×
224

225
      def in_process_statuses
×
226
        ["Acquisition technical services", "Acquisitions and Cataloging", "In Process"]
×
227
      end
×
228
  end
×
229
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