• 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

98.77
/app/models/requests/form_decorator.rb
1
# frozen_string_literal: true
2
module Requests
1✔
3
  # This class is responsible for generating the visual aspects of the Request object for the form
4
  class FormDecorator
1✔
5
    delegate :patron,
1✔
6
             :ctx, :system_id, :mfhd, :holdings, :default_pick_ups,
7
             :serial?, :any_loanable_copies?, :requestable?, :thesis?, :numismatics?, :eligible_for_library_services?,
8
             :user_name, :email, # passed to request as login options on the request form
9
             to: :request
10
    delegate :content_tag, :hidden_field_tag, :concat, to: :view_context
1✔
11

12
    alias bib_id system_id
1✔
13

14
    attr_reader :request, :view_context, :first_filtered_requestable, :non_requestable_message, :back_to_record_url
1✔
15
    def initialize(request, view_context, back_to_record_url)
1✔
16
      @request = request
75✔
17
      @view_context = view_context
75✔
18
      @requestable_list = request.requestable.map { |req| RequestableDecorator.new(req, view_context) }
627✔
19
      @first_filtered_requestable = RequestableDecorator.new(request.first_filtered_requestable, view_context)
75✔
20
      @non_requestable_message = "See Circulation Desk, there are no requestable items for this record"
75✔
21
      @back_to_record_url = back_to_record_url
75✔
22
    end
23

24
    def requestable
1✔
25
      @requestable_list
3,166✔
26
    end
27

28
    # rubocop:disable Rails/OutputSafety
29
    def patron_message
1✔
30
      return '' if patron.guest?
70✔
31
      return '' if eligible_for_library_services?
70✔
32
      "<div class='alert alert-warning'>#{I18n.t('requests.account.cas_user_no_barcode_msg')}</div>".html_safe
21✔
33
    end
34

35
    def hidden_fields
1✔
36
      hidden_request_tags = ''
68✔
37
      hidden_request_tags += hidden_field_tag "bib[id]", "", value: bib_id
68✔
38
      request.hidden_field_metadata.each do |key, value|
68✔
39
        hidden_request_tags += hidden_field_tag "bib[#{key}]", "", value:
272✔
40
      end
41
      hidden_request_tags.html_safe
68✔
42
    end
43
    # rubocop:enable Rails/OutputSafety
44

45
    def any_will_submit_via_form?
1✔
46
      return false if requestable.compact_blank.blank? || !eligible_for_library_services?
63✔
47
      requestable.map(&:will_submit_via_form?).any? || any_fill_in_eligible?
45✔
48
    end
49

50
    def any_fill_in_eligible?
1✔
51
      return false unless eligible_for_library_services?
100✔
52
      return false if patron.alma_provider?
80✔
53

54
      fill_in = false
67✔
55
      unless requestable.one? && (requestable.first.services & ["on_order", "online"]).present?
67✔
56
        if requestable.any? do |requestable_decorator|
63✔
57
          !(requestable_decorator.services & fill_in_services).empty?
95✔
58
        end
59
          if any_items?
26✔
60
            fill_in = true if any_enumerated?
22✔
61
          elsif request.too_many_items?
4✔
62
            fill_in = true
×
63
          else
64
            fill_in = any_circulate?
4✔
65
          end
66
        end
67
      end
68
      fill_in
67✔
69
    end
70

71
    def single_item_request?
1✔
72
      requestable.size == 1 && !any_fill_in_eligible?
504✔
73
    end
74

75
    def only_aeon?
1✔
76
      requestable.map(&:aeon?).all?
132✔
77
    end
78

79
    def location_label
1✔
80
      return "" if holding.blank?
127✔
81
      first_requestable_item = requestable.first.item if any_items?
127✔
82
      if any_items? && first_requestable_item.temp_loc_other_than_resource_sharing?
127✔
83
        current_location_label
4✔
84
      else
85
        permanent_location_label
123✔
86
      end
87
    end
88

89
    def current_location_label
1✔
90
      label = holding["current_library"]
4✔
91
      current_holding_location = holding['current_location']
4✔
92
      label += " - #{current_holding_location}" if current_holding_location.present?
4✔
93
      label
4✔
94
    end
95

96
    def permanent_location_label
1✔
97
      label = holding["library"]
123✔
98
      holding_location = holding['location']
123✔
99
      label += " - #{holding_location}" if holding_location.present?
123✔
100
      label
123✔
101
    end
102

103
    def holding
1✔
104
      first_requestable_item = requestable.first.item if any_items?
570✔
105
      if any_items? && first_requestable_item.temp_loc_other_than_resource_sharing?
570✔
106
        holdings[first_requestable_item["temp_location_code"]]
18✔
107
      else
108
        holdings[mfhd]
552✔
109
      end
110
    end
111

112
    def alma_provider_item_unavailable?
1✔
113
      patron.alma_provider? && !(any_available? || any_in_process?)
68✔
114
    end
115

116
    private
1✔
117

118
      def fill_in_services
1✔
119
        ["annex", "recap_no_items", "on_shelf"]
95✔
120
      end
121

122
      def any_circulate?
1✔
123
        requestable.any?(&:circulates?)
4✔
124
      end
125

126
      def any_enumerated?
1✔
127
        requestable.any?(&:enumerated?)
22✔
128
      end
129

130
      def any_items?
1✔
131
        requestable.any?(&:item_data?)
1,420✔
132
      end
133

134
      def any_available?
1✔
135
        requestable.any?(&:available?)
11✔
136
      end
137

138
      def any_in_process?
1✔
139
        requestable.any?(&:in_process?)
5✔
140
      end
141
  end
142
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