• 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

38.64
/app/services/stackmap_service.rb
1
# frozen_string_literal: true
2

3
class StackmapService
1✔
4
  # A url to the stackmap for the bib record
5
  class Url
1✔
6
    # Constructor
7
    # @param document [SolrDocument] Solr document for bib record
8
    # @param loc [String] Bib record location code
9
    # @param cn [String] optional provided call number
10
    def initialize(document:, loc:, cn: nil)
1✔
11
      @document = document
×
12
      @loc = loc
×
13
      @cn = cn
×
14
    end
15

16
    # Return the correct stackmap url ased on the location information of the bib record
17
    # @return [String] stackmap url
18
    def url
1✔
19
      if valid?
×
20
        if StackmapService::Url.missing_stackmap_reserves.include? @loc
×
21
          StackmapService::Url.missing_stackmap_reserves[@loc]
×
22
        elsif stackmap_libs.include? lib
×
23
          stackmap_url
×
24
        else
25
          fallback_url
×
26
        end
27
      else
28
        fallback_url
×
29
      end
30
    end
31

32
    def preferred_callno
1✔
33
      if by_title_locations.include? @loc
×
34
        @document['title_display']
×
35
      else
36
        @cn || @document['call_number_browse_s']&.first
×
37
      end
38
    end
39

40
    def location_label
1✔
41
      return nil if holding_location.nil?
×
42
      holding_location[:label].presence || holding_location[:library][:label]
×
43
    end
44

45
    def self.missing_stackmap_reserves
1✔
46
      {
×
47
        'arch$res3hr' => 'https://library.princeton.edu/architecture',
48
        'stokes$respiapr' => 'https://library.princeton.edu/stokes',
49
        'plasma$res' => 'https://library.princeton.edu/plasma-physics',
50
        'lewis$gr' => 'https://library.princeton.edu/lewis'
51
      }
52
    end
53

54
    private
1✔
55

56
      def stackmap_url
1✔
57
        stackmap_url = 'https://princeton.stackmap.com/view/'
×
58
        stackmap_params = {
59
          callno:,
×
60
          location: @loc,
61
          library: holding_location[:library][:label]
62
        }
63
        "#{stackmap_url}?#{stackmap_params.to_query}"
×
64
      end
65

66
      # redirects to catalog record page if location or call number is missing_stackmap_reserves
67
      # takes user to catalog home page if @document (bibid) is missing
68
      def fallback_url
1✔
69
        "/catalog/#{@document.to_param}"
×
70
      end
71

72
      def bibid
1✔
73
        @bibid ||= @document[:id]
×
74
      end
75

76
      # use the optionally provided call number unless if by title location
77
      def callno
1✔
78
        @cn = preferred_callno
×
79
      end
80

81
      def stackmap_libs
1✔
82
        %w[arch eastasian engineer lewis mendel stokes firestone]
×
83
      end
84

85
      def by_title_locations
1✔
86
        %w[lewis$serial plasma$ps stokes$sprps stokes$spiaps]
×
87
      end
88

89
      def holding_location
1✔
90
        @holding_location ||= Bibdata.holding_locations[@loc]
×
91
      end
92

93
      def lib
1✔
94
        @lib ||= holding_location[:library][:code]
×
95
      end
96

97
      def valid?
1✔
98
        !holding_location.nil? && !@document.nil? && !callno.nil?
×
99
      end
100
  end
101
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