Skip to content

Commit bbaa341

Browse files
authored
Merge pull request #735 from IU-Libraries-Joint-Development/essi-2206_doff_fedora_in_public
Essi-2206 doff fedora in public
2 parents 74bf268 + 2976a5b commit bbaa341

12 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module ESSI
4+
module OptimizedAdminSetLookup
5+
extend ActiveSupport::Concern
6+
7+
def admin_set_id
8+
# Replaces following from AllinsonFlex::DynamicPresenterBehavior
9+
# @admin_set_id ||= AdminSet.where(title: self.admin_set).first&.id
10+
11+
@admin_set_id ||= ActiveFedora::SolrService.query(
12+
"has_model_ssim:AdminSet AND title_sim:\"#{admin_set.first}\"", fl: 'id', rows: 1).first&.[]('id')
13+
end
14+
end
15+
end

app/presenters/hyrax/archival_material_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ArchivalMaterialPresenter < Hyrax::WorkShowPresenter
1111
to: :solr_document
1212

1313
include AllinsonFlex::DynamicPresenterBehavior
14+
include ESSI::OptimizedAdminSetLookup
1415
self.model_class = ::ArchivalMaterial
1516
include ESSI::PresentsCustomRenderedAttributes
1617
delegate(*delegated_properties, to: :solr_document)

app/presenters/hyrax/bib_record_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class BibRecordPresenter < Hyrax::WorkShowPresenter
77
include ESSI::PresentsStructure
88
delegate :series, to: :solr_document
99
include AllinsonFlex::DynamicPresenterBehavior
10+
include ESSI::OptimizedAdminSetLookup
1011
self.model_class = ::BibRecord
1112
include ESSI::PresentsCustomRenderedAttributes
1213
delegate(*delegated_properties, to: :solr_document)

app/presenters/hyrax/image_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ImagePresenter < Hyrax::WorkShowPresenter
66
include ESSI::PresentsOCR
77
include ESSI::PresentsStructure
88
include AllinsonFlex::DynamicPresenterBehavior
9+
include ESSI::OptimizedAdminSetLookup
910
self.model_class = ::Image
1011
include ESSI::PresentsCustomRenderedAttributes
1112
delegate(*delegated_properties, to: :solr_document)

app/presenters/hyrax/paged_resource_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class PagedResourcePresenter < Hyrax::WorkShowPresenter
1111
to: :solr_document
1212

1313
include AllinsonFlex::DynamicPresenterBehavior
14+
include ESSI::OptimizedAdminSetLookup
1415
self.model_class = ::PagedResource
1516
include ESSI::PresentsCustomRenderedAttributes
1617
delegate(*delegated_properties, to: :solr_document)

app/presenters/hyrax/scientific_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ScientificPresenter < Hyrax::WorkShowPresenter
66
include ESSI::PresentsOCR
77
include ESSI::PresentsStructure
88
include AllinsonFlex::DynamicPresenterBehavior
9+
include ESSI::OptimizedAdminSetLookup
910
self.model_class = ::Scientific
1011
include ESSI::PresentsCustomRenderedAttributes
1112
delegate(*delegated_properties, to: :solr_document)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Extensions
2+
module AllinsonFlex
3+
module OptimizedAdminSetLookup
4+
private
5+
6+
# Modified from AllinsonFlex::DynamicSchemaService to avoid fedora request
7+
def context_for(admin_set_id:)
8+
cxt = ::AllinsonFlex::Context.find_metadata_context_for(admin_set_id: admin_set_id)
9+
if cxt.blank?
10+
raise ::AllinsonFlex::NoAllinsonFlexContextError.new(
11+
"No Metadata Context for Admin Set #{admin_set_id}"
12+
)
13+
end
14+
@context = cxt.name
15+
@context_id = cxt.id
16+
end
17+
end
18+
end
19+
end

lib/extensions/allinson_flex_extensions.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
Hyrax::Admin::PermissionTemplatesController.prepend Extensions::AllinsonFlex::PrependPermissionTemplatesController
1515
AllinsonFlex::ProfilesController.prepend Extensions::AllinsonFlex::PrependProfilesController
1616

17+
# DynamicSchemaService
18+
AllinsonFlex::DynamicSchemaService.prepend Extensions::AllinsonFlex::OptimizedAdminSetLookup
1719
# forms
1820
Hyrax::Forms::AdminSetForm.prepend Extensions::AllinsonFlex::PrependAdminSetForm
1921
Hyrax::Forms::PermissionTemplateForm.prepend Extensions::AllinsonFlex::PrependPermissionTemplateForm

lib/extensions/extensions.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ def attribute_will_change!(attr)
126126
# Hyrax Work Type selection
127127
Hyrax::SelectTypeListPresenter.prepend Extensions::Hyrax::SelectTypeListPresenter::OptionsForSelect
128128

129+
# ESSI-2206 Load from solr for public site
130+
Hyrax::CollectionsController.prepend Extensions::Hyrax::CollectionsController::LoadFromSolr
131+
129132
# return false for render_bookmarks_control? in CollectionsController
130133
Hyrax::CollectionsController.prepend Extensions::Hyrax::CollectionsController::RenderBookmarksControl
131134

lib/extensions/hyrax/collection_presenter/total_counts.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def total_viewable_works
2424
def total_viewable_collections
2525
num_collections
2626
end
27+
28+
# Uses blank? in place of nil? to handle empty array
29+
def total_parent_collections
30+
parent_collections.blank? ? 0 : parent_collections.response['numFound']
31+
end
2732
end
2833
end
2934
end

0 commit comments

Comments
 (0)