• 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

54.55
/app/models/requests/illiad_patron.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client'
1✔
3
require './lib/orangelight/illiad_account'
1✔
4

5
module Requests
1✔
6
  # Creates patron for Illiad requests
7
  class IlliadPatron < IlliadClient
1✔
8
    attr_reader :netid, :patron_id, :patron, :attributes
1✔
9

10
    def initialize(patron)
1✔
11
      super()
10✔
12
      @patron = patron
10✔
13
      @patron_id = patron.patron_id
10✔
14
      @netid = patron.netid
10✔
15
      @attributes = illiad_patron_attributes
10✔
16
    end
17

18
    def illiad_patron
1✔
19
      get_json_response
10✔
20
    end
21

22
    def create_illiad_patron
1✔
23
      return nil if patron.blank?
×
24

25
      patron_response = post_json_response(url: 'ILLiadWebPlatform/Users', body: attributes.to_json)
×
26
      patron_response = illiad_patron if patron_response.blank? && error.dig("ModelState", "UserName") == ["Username #{netid} already exists."]
×
27
      patron_response
×
28
    end
29

30
    private
1✔
31

32
      def illiad_patron_attributes
1✔
33
        return {} if status.blank?
10✔
34
        return {} if illiad_status.blank?
7✔
35
        {
36
          "Username" => netid, "ExternalUserId" => netid, "FirstName" => patron.first_name,
7✔
37
          "LastName" => patron.last_name, "LoanDeliveryMethod" => "Hold for Pickup", "NotificationMethod" => "Electronic",
38
          "EmailAddress" => patron.active_email, "DeliveryMethod" => "Hold for Pickup",
39
          "Phone" => patron.telephone, "Status" => illiad_status, "Number" => patron.university_id,
40
          "AuthType" => "Default", "NVTGC" => "ILL", "Department" => department, "Web" => true,
41
          "Address" => addresses&.shift, "Address2" => addresses&.join(', '), "City" => "Princeton", "State" => "NJ",
42
          "Zip" => "08544", "SSN" => patron.barcode, "Cleared" => "Yes", "Site" => "Firestone"
43
        }
44
      end
45

46
      def addresses
1✔
47
        @addresses ||= patron.address&.split('$')
14✔
48
      end
49

50
      def status
1✔
51
        patron.status
38✔
52
      end
53

54
      def pustatus
1✔
55
        patron.pustatus
42✔
56
      end
57

58
      def title
1✔
59
        patron.title
×
60
      end
61

62
      def department
1✔
63
        patron.department
7✔
64
      end
65

66
      def illiad_status
1✔
67
        return nil if pustatus.blank? || pustatus[0] == 'x'
14✔
68

69
        if status == "staff"
14✔
70
          illiad_staff_status
×
71
        elsif status == "student"
14✔
72
          student_mappings = { "gradetdc" => "GS - Graduate Student", "undergraduate" => "U - Undergraduate", "graduate" => "GS - Graduate Student" }
14✔
73
          student_mappings[pustatus]
14✔
74
        elsif status == "faculty"
×
75
          if title.present? && title.include?("Visiting")
×
76
            "F - Visiting Faculty"
×
77
          else
78
            "F - Faculty"
×
79
          end
80
        end
81
      end
82

83
      def illiad_staff_status
1✔
84
        if department.present? && department.include?("Library")
×
85
          "GS - Library Staff"
×
86
        elsif title.present?
×
87
          illiad_staff_title_status(ldap_title: patron.title)
×
88
        else
89
          "GS - University Staff"
×
90
        end
91
      end
92

93
      def illiad_staff_title_status(ldap_title:)
1✔
94
        if ldap_title.include?("Visiting Research")
×
95
          "GS - Visiting Research Scholar"
×
96
        elsif title.include?("Senior Research Scholar")
×
97
          "F - Senior Research Scholar"
×
98
        elsif title.include?("Research Scholar")
×
99
          "F - Research Scholar"
×
100
        elsif title.include?("Senior Professional")
×
101
          "F - Senior Professional Specialist"
×
102
        elsif title.match?(/Post*doc*Reseach*/i)
×
103
          "GS - Post doc Research Associate"
×
104
        elsif title.match?(/Post*doc*Fellow*/i)
×
105
          "F - Postdoctoral Fellow -- Teaching"
×
106
        elsif title.match?(/Visit*Fellow*/i)
×
107
          "GS - Visiting Fellow"
×
108
        else
109
          "GS - University Staff"
×
110
        end
111
      end
112
  end
113
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