• 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

94.85
/app/models/requests/requestable_decorator.rb
1
# frozen_string_literal: true
2
module Requests
1✔
3
  class RequestableDecorator
1✔
4
    delegate :system_id, :services, :charged?, :annex?, :on_reserve?,
1✔
5
             :ask_me?, :aeon_request_url, :temp_loc_other_than_resource_sharing?, :call_number, :eligible_for_library_services?,
6
             :holding_library_in_library_only?, :holding_library, :bib, :circulates?, :item_data?, :recap_edd?, :clancy_available?,
7
             :holding, :item_location_code, :item?, :item, :partner_holding?, :status, :status_label, :use_restriction?, :library_code, :enum_value, :item_at_clancy?,
8
             :cron_value, :illiad_request_parameters, :location_label, :aeon?, :patron, :held_at_marquand_library?,
9
             :ill_eligible?, :scsb_in_library_use?, :pick_up_locations, :on_shelf?, :pending?, :recap?, :recap_pf?, :illiad_request_url, :available?,
10
             :on_order?, :in_process?, :alma_managed?, :title, :cul_avery?, :cul_music?,
11
             :pick_up_location_code, :enumerated?, to: :requestable
12
    delegate :content_tag, :hidden_field_tag, :concat, to: :view_context
1✔
13

14
    alias bib_id system_id
1✔
15

16
    attr_reader :requestable, :view_context
1✔
17
    def initialize(requestable, view_context)
1✔
18
      @requestable = requestable
638✔
19
      @view_context = view_context
638✔
20
    end
21

22
    ## If the item doesn't have any item level data use the holding mfhd ID as a unique key
23
    ## when one is needed. Primarily for non-barcoded Annex items.
24
    def preferred_request_id
1✔
25
      requestable.id.presence || holding.mfhd_id
7,113✔
26
    end
27

28
    def digitize?
1✔
29
      return false unless patron.cas_provider? # only allow digitization for cas users
997✔
30
      eligible_for_library_services? && (item_data? || !circulates?) && (on_shelf_edd? || recap_edd? || marquand_edd?) && !request_status?
894✔
31
    end
32

33
    def fill_in_digitize?
1✔
34
      return false unless patron.cas_provider? # only allow fill in digitization for cas users
22✔
35
      !item_data? || digitize?
22✔
36
    end
37

38
    def pick_up?
1✔
39
      return false if !eligible_for_library_services? || (!patron.cas_provider? && !off_site?)
456✔
40
      item_data? && (on_shelf? || recap? || annex?) && circulates? && !holding_library_in_library_only? && !scsb_in_library_use? && !request_status?
426✔
41
    end
42

43
    def fill_in_pick_up?
1✔
44
      return false unless eligible_for_library_services?
161✔
45
      !item_data? || pick_up?
157✔
46
    end
47

48
    def request?
1✔
49
      return false unless eligible_for_library_services?
75✔
50
      request_status?
45✔
51
    end
52

53
    def request_status?
1✔
54
      on_order? || in_process? || ill_eligible? || services.empty?
1,011✔
55
    end
56

57
    def will_submit_via_form?
1✔
58
      return false unless eligible_for_this_item?
1,544✔
59
      digitize? || pick_up? || scsb_in_library_use? || ill_eligible? || on_order? || in_process? || off_site?
423✔
60
    end
61

62
    def on_shelf_edd?
1✔
63
      services.include?('on_shelf_edd')
765✔
64
    end
65

66
    def marquand_edd?
1✔
67
      !(['clancy_edd', 'clancy_unavailable', 'marquand_edd'] & services).empty?
113✔
68
    end
69

70
    def in_library_use_required?
1✔
71
      available? && (!held_at_marquand_library? || !item_at_clancy? || clancy_available?) && ((off_site? && !circulates?) || holding_library_in_library_only? || scsb_in_library_use?)
69✔
72
    end
73

74
    def off_site?
1✔
75
      recap? || annex? || item_at_clancy? || held_at_marquand_library?
1,287✔
76
    end
77

78
    def off_site_location
1✔
79
      if clancy_available?
260✔
80
        "clancy" # at clancy and available
×
81
      elsif item_at_clancy?
260✔
82
        "clancy_unavailable" # at clancy but not available
×
83
      elsif recap? && (holding_library == "marquand" || requestable.cul_avery?)
260✔
84
        "recap_marquand"
4✔
85
      elsif recap?
256✔
86
        "recap"
92✔
87
      else
88
        library_code
164✔
89
      end
90
    end
91

92
    def create_fill_in_requestable
1✔
93
      fill_in_req = Requestable.new(bib:, holding:, item: nil, location: location.to_h, patron:)
11✔
94
      fill_in_req.replace_existing_services services
11✔
95
      RequestableDecorator.new(fill_in_req, view_context)
11✔
96
    end
97

98
    def libcal_url
1✔
99
      code = if off_site? && !held_at_marquand_library? && location.holding_library.present?
7✔
100
               location.holding_library[:code]
4✔
101
             elsif !off_site? || held_at_marquand_library?
3✔
102
               location.library_code
×
103
             else
104
               "firestone"
3✔
105
             end
106
      Libcal.url(code)
7✔
107
    end
108

109
    def status_badge
1✔
110
      content_tag(:span, requestable.status, class: "availability--label badge #{css_class}")
510✔
111
    end
112

113
    def css_class
1✔
114
      if requestable.status == "Available"
510✔
115
        "bg-success"
490✔
116
      else
117
        "bg-danger"
20✔
118
      end
119
    end
120

121
    def aeon_url(_request_ctx)
1✔
122
      if requestable.alma_managed?
6✔
123
        requestable.aeon_request_url
6✔
124
      else
125
        aeon_url = Requests.config[:aeon_base]
×
126
        "#{aeon_url}?#{requestable.aeon_mapped_params.to_query}"
×
127
      end
128
    end
129

130
    def delivery_location_label
1✔
131
      if requestable.held_at_marquand_library? ||
26✔
132
         (recap? && (requestable.holding_library == "marquand" || requestable.cul_avery? || requestable.hl_art?))
26✔
133
        "Marquand Library at Firestone"
4✔
134
      elsif requestable.cul_music?
22✔
135
        "Mendel Music Library"
2✔
136
      else
137
        first_delivery_location[:label]
20✔
138
      end
139
    end
140

141
    def delivery_location_code
1✔
142
      if requestable.cul_avery? || requestable.hl_art?
12✔
143
        "PJ"
1✔
144
      elsif requestable.cul_music?
11✔
145
        "PK"
1✔
146
      else
147
        first_delivery_location[:gfa_pickup] || "PA"
10✔
148
      end
149
    end
150

151
    def no_services?
1✔
152
      !(digitize? || pick_up? || aeon? || ill_eligible? || in_library_use_required? || request? || on_shelf? || off_site?)
135✔
153
    end
154

155
    def location
1✔
156
      Location.new requestable.location
280✔
157
    end
158

159
    private
1✔
160

161
      def first_delivery_location
1✔
162
        delivery_locations = Location.new(requestable.location).delivery_locations
30✔
163
        if delivery_locations.blank?
30✔
164
          {}
2✔
165
        else
166
          delivery_locations.first
28✔
167
        end
168
      end
169

170
      def eligible_for_this_item?
1✔
171
        return false unless eligible_for_library_services?
1,544✔
172

173
        patron.cas_provider? || (patron.alma_provider? && off_site? && (available? || in_process?))
1,512✔
174
      end
175
  end
176
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