Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove patron address pages #529

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/components/patron_field_component.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/components/patron_field_component.rb

This file was deleted.

40 changes: 0 additions & 40 deletions app/controllers/patrons_controller.rb

This file was deleted.

68 changes: 0 additions & 68 deletions app/helpers/patron_helper.rb

This file was deleted.

29 changes: 0 additions & 29 deletions app/models/patron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,6 @@ def library
fields.dig('library', 'key')
end

def email
extract_address_data('EMAIL')
end

def state
address[:city_state]&.chomp&.last 2
end

def city
address[:city_state]&.split(',')&.first
end

def address
{
street1: extract_address_data('STREET1'),
street2: extract_address_data('STREET2'),
city_state: extract_address_data('CITY/STATE'),
zip: extract_address_data('ZIP')
}
end

def custom_information
fields['customInformation']
end
Expand All @@ -155,14 +134,6 @@ def fields
record['fields']
end

def address_fields
fields['address1']
end

def extract_address_data(address_field)
address_fields.find { |a| a&.dig('fields', 'code', 'key') == address_field }&.dig('fields', 'data') || nil
end

def standing_code
fields.dig('standing', 'key')
end
Expand Down
3 changes: 0 additions & 3 deletions app/models/patron_argument_error.rb

This file was deleted.

45 changes: 0 additions & 45 deletions app/services/symphony_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class SymphonyClient

DELAY = 0.75
MAX_WAIT_TIME = 30
SAFE_PATRON_ADDRESS_FIELDS = [:email, :street1, :street2, :zip].freeze

def login(user_id, password)
response = request('/user/staff/login', method: :post, json: {
Expand Down Expand Up @@ -127,27 +126,6 @@ def place_hold(patron, session_token, item_barcode, hold_args)
json: body
end

def update_patron_info(patron:, params:, session_token:)
body = {
"resource": '/user/patron',
"key": patron.key,
"fields": {
"lastName": params[:last_name],
"middleName": params[:middle_name],
"firstName": params[:first_name],
"suffix": params[:suffix],
"address1": patron_address(params)
}
}

authenticated_request "/user/patron/key/#{patron.key}",
headers: {
'x-sirs-sessionToken': session_token
},
method: :put,
json: body
end

# Accepts the Libraries' lending policy/opts the user into wage garnishment.
# Changes the patron's standing from BARRED to OK and sets the garnish date to today's date.
def accept_lending_policy(patron:, session_token:)
Expand Down Expand Up @@ -257,29 +235,6 @@ def get_patron_record(remote_user, session_token)

private

def patron_address(params)
params.permit(SAFE_PATRON_ADDRESS_FIELDS)
.to_h
.transform_keys(&:camelize)
.transform_keys(&:upcase)
.map { |field, value| patron_address_1_template field: field, value: value }
.push patron_address_1_template field: 'CITY/STATE', value: "#{params[:city]}, #{params[:state]}"
end

def patron_address_1_template(field:, value:)
{
"resource": '/user/patron/address1',
"fields":
{
"code": {
"resource": '/policy/patronAddress1',
"key": field
},
"data": value
}
}
end

def time_left_to_request_again?(start)
return true if DateTime.now < (start + MAX_WAIT_TIME.seconds)

Expand Down
1 change: 1 addition & 0 deletions app/views/content/_user_util_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="row">
<div class="col-md-12">
<ul class="card-body">
<li><%= link_to t('user_util_links.update_address'), 'https://accounts.psu.edu' %></li>
<li><%= link_to t('user_util_links.feedback'), 'https://libraries.psu.edu/website-feedback' %></li>
<li><%= link_to t('user_util_links.questions'), 'https://libraries.psu.edu/services/borrow-renew' %></li>
<li><%= link_to t('user_util_links.borrowing'), 'https://libraries.psu.edu/services/borrow-renew/borrowing-privileges' %></li>
Expand Down
3 changes: 0 additions & 3 deletions app/views/layouts/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<%= render partial: 'shared/nav_link', locals: { name: 'Checkouts/Renewals', path: checkouts_path } %>
<%= render partial: 'shared/nav_link', locals: { name: 'Holds', path: holds_path } %>
<%= render partial: 'shared/nav_link', locals: { name: 'Bills', path: fines_path } %>
<% if patron&.valid? %>
<%= render partial: 'shared/nav_link', locals: { name: 'Update Address', path: patron_path(patron) } %>
<% end %>
</ul>
</div>
</div>
Expand Down
85 changes: 0 additions & 85 deletions app/views/patrons/edit.html.erb

This file was deleted.

26 changes: 0 additions & 26 deletions app/views/patrons/show.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

en:
user_util_links:
update_address: 'Update your address and other information at accounts.psu.edu'
borrowing: 'Borrowing privileges: information about loan periods, check out limits, and more'
questions: 'Frequently asked questions: borrowing and renewing'
user_privacy: 'Information about library user privacy'
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
resources :summaries, :fines, :checkouts, only: [:index]
resources :holds, only: [:index, :new, :create]
resources :redis_jobs, only: [:show, :destroy]
resources :patrons, only: [:show, :edit, :update]

patch '/holds/batch', to: 'holds#batch_update', as: :holds_batch_update
delete '/holds/batch', to: 'holds#batch_destroy', as: :holds_batch_destroy
Expand Down
Loading