• 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/form_decorator.rb
1
# frozen_string_literal: true
2
module Requests
×
3
  # This class is responsible for generating the visual aspects of the Request object for the form
4
  class FormDecorator
×
5
    delegate :patron,
×
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
×
11

12
    alias bib_id system_id
×
13

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

24
    def requestable
×
25
      @requestable_list
×
26
    end
×
27

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

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

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

50
    def any_fill_in_eligible?
×
51
      return false unless eligible_for_library_services?
×
52
      return false if patron.alma_provider?
×
53

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

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

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

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

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

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

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

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

116
    private
×
117

118
      def fill_in_services
×
119
        ["annex", "recap_no_items", "on_shelf"]
×
120
      end
×
121

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

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

130
      def any_items?
×
131
        requestable.any?(&:item_data?)
×
132
      end
×
133

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

138
      def any_in_process?
×
139
        requestable.any?(&:in_process?)
×
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