diff --git a/app/controllers/purchase_requests_controller.rb b/app/controllers/purchase_requests_controller.rb index 98d08cf0d7..456e8c2b8a 100644 --- a/app/controllers/purchase_requests_controller.rb +++ b/app/controllers/purchase_requests_controller.rb @@ -81,7 +81,8 @@ def show def new @purchase_request = current_user.purchase_requests.new(purchase_request_params) if defined?(EnjuBookmark) - @purchase_request.title = Bookmark.get_title_from_url(@purchase_request.url) unless @purchase_request.title? + bookmark = Bookmark.new + @purchase_request.title = bookmark.get_title_from_url(@purchase_request.url) unless @purchase_request.title? end end diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 8b463a9e80..7109c05fab 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -64,11 +64,12 @@ def get_title end end - def self.get_title_from_url(url) + def get_title_from_url(url) return if url.blank? return unless Addressable::URI.parse(url).host - if manifestation_id = url.bookmarkable_id - self.manifestation = Manifestation.find(manifestation_id) + + if manifestation_id == url.bookmarkable_id + bookmark.manifestation = Manifestation.find(manifestation_id) return manifestation.original_title end unless manifestation diff --git a/app/views/manifestations/_reservation.html.erb b/app/views/manifestations/_reservation.html.erb index 10f32e0fe6..a79126921c 100644 --- a/app/views/manifestations/_reservation.html.erb +++ b/app/views/manifestations/_reservation.html.erb @@ -4,11 +4,9 @@
(<%= link_to_if(current_user.has_role?('Librarian'), t('page.number_of_reservations', count: @reserved_count), reserves_path(query: "manifestation_id_i:#{@manifestation.id}")) -%>) <%- else -%> - <%- end -%> <% else %> <% unless Pundit.policy_scope!(current_user, @manifestation.items).for_checkout.empty? %>