• 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_decorator.rb
1
# frozen_string_literal: true
2
module Requests
×
3
  class RequestableDecorator
×
4
    delegate :system_id, :services, :charged?, :annex?, :on_reserve?,
×
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
×
13

14
    alias bib_id system_id
×
15

16
    attr_reader :requestable, :view_context
×
17
    def initialize(requestable, view_context)
×
18
      @requestable = requestable
×
19
      @view_context = view_context
×
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
×
25
      requestable.id.presence || holding.mfhd_id
×
26
    end
×
27

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

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

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

43
    def fill_in_pick_up?
×
44
      return false unless eligible_for_library_services?
×
45
      !item_data? || pick_up?
×
46
    end
×
47

48
    def request?
×
49
      return false unless eligible_for_library_services?
×
50
      request_status?
×
51
    end
×
52

53
    def request_status?
×
54
      on_order? || in_process? || ill_eligible? || services.empty?
×
55
    end
×
56

57
    def will_submit_via_form?
×
58
      return false unless eligible_for_this_item?
×
59
      digitize? || pick_up? || scsb_in_library_use? || ill_eligible? || on_order? || in_process? || off_site?
×
60
    end
×
61

62
    def on_shelf_edd?
×
63
      services.include?('on_shelf_edd')
×
64
    end
×
65

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

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

74
    def off_site?
×
75
      recap? || annex? || item_at_clancy? || held_at_marquand_library?
×
76
    end
×
77

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

92
    def create_fill_in_requestable
×
93
      fill_in_req = Requestable.new(bib:, holding:, item: NullItem.new({}), location: location.to_h, patron:)
×
94
      fill_in_req.replace_existing_services services
×
95
      RequestableDecorator.new(fill_in_req, view_context)
×
96
    end
×
97

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

109
    def status_badge
×
110
      content_tag(:span, status, class: "availability--label badge #{css_class}") if status
×
111
    end
×
112

113
    def css_class
×
114
      if requestable.status == "Available"
×
115
        "bg-success"
×
116
      else
×
117
        "bg-danger"
×
118
      end
×
119
    end
×
120

121
    def aeon_url(_request_ctx)
×
122
      if requestable.alma_managed?
×
123
        requestable.aeon_request_url
×
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
×
131
      if requestable.held_at_marquand_library? ||
×
132
         (recap? && (requestable.holding_library == "marquand" || requestable.cul_avery? || requestable.hl_art?))
×
133
        "Marquand Library at Firestone"
×
134
      elsif requestable.cul_music?
×
135
        "Mendel Music Library"
×
136
      else
×
137
        first_delivery_location[:label]
×
138
      end
×
139
    end
×
140

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

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

155
    def location
×
156
      Location.new requestable.location
×
157
    end
×
158

159
    private
×
160

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

170
      def eligible_for_this_item?
×
171
        return false unless eligible_for_library_services?
×
172

173
        patron.cas_provider? || (patron.alma_provider? && off_site? && (available? || in_process?))
×
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