Skip to content

Commit

Permalink
Merge pull request #1995 from samvera/fix-block-content-error
Browse files Browse the repository at this point in the history
register and add missing methods to avoid content block errors
  • Loading branch information
Shana Moore authored Sep 25, 2023
2 parents 6905712 + ed161f8 commit 880b3d2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 33 deletions.
31 changes: 16 additions & 15 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def self.uploaded_field
config.add_facet_field 'file_format_sim', limit: 5
config.add_facet_field 'member_of_collections_ssim', limit: 5, label: 'Collections'


# TODO deal with part of facet changes
# TODO: deal with part of facet changes
# config.add_facet_field solr_name("part", :facetable), limit: 5, label: 'Part'
# config.add_facet_field solr_name("part_of", :facetable), limit: 5
# removed # config.add_facet_field solr_name("file_format", :facetable), limit: 5
Expand All @@ -123,16 +122,16 @@ def self.uploaded_field
# handler defaults, or have no facets.
config.add_facet_fields_to_solr_request!

# TODO ROB
# # Prior to this change, the applications specific translations were not loaded. Dogbiscuits were assuming the translations were already loaded.
# Rails.root.glob("config/locales/*.yml").each do |path|
# I18n.load_path << path.to_s
# end
# I18n.backend.reload!
# index_props = DogBiscuits.config.index_properties.collect do |prop|
# { prop => index_options(prop, DogBiscuits.config.property_mappings[prop]) }
# end
# add_index_field config, index_props
# TODO: ROB
# # Prior to this change, the applications specific translations were not loaded. Dogbiscuits were assuming the translations were already loaded.
# Rails.root.glob("config/locales/*.yml").each do |path|
# I18n.load_path << path.to_s
# end
# I18n.backend.reload!
# index_props = DogBiscuits.config.index_properties.collect do |prop|
# { prop => index_options(prop, DogBiscuits.config.property_mappings[prop]) }
# end
# add_index_field config, index_props

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
Expand Down Expand Up @@ -203,8 +202,8 @@ def self.uploaded_field
# since we aren't specifying it otherwise.
config.add_search_field('all_fields', label: 'All Fields', include_in_advanced_search: false) do |field|
all_names = config.show_fields.values.map(&:field).join(" ")
# TODO ROB all_names = (config.show_fields.values.map { |v| v.field.to_s } +
# DogBiscuits.config.all_properties.map { |p| "#{p}_tesim" }).uniq.join(" ")
# TODO: ROB all_names = (config.show_fields.values.map { |v| v.field.to_s } +
# DogBiscuits.config.all_properties.map { |p| "#{p}_tesim" }).uniq.join(" ")
title_name = 'title_tesim'
field.solr_parameters = {
qf: "#{all_names} file_format_tesim all_text_timv",
Expand Down Expand Up @@ -233,7 +232,7 @@ def self.uploaded_field
end

config.add_search_field('creator') do |field|
# TODO ROB field.label = "Author"
# TODO: ROB field.label = "Author"
field.solr_parameters = { "spellcheck.dictionary": "creator" }
solr_name = 'creator_tesim'
field.solr_local_parameters = {
Expand Down Expand Up @@ -276,7 +275,9 @@ def self.uploaded_field
}
end

# rubocop:disable Lint/UselessAssignment
date_fields = ['date_created_tesim', 'sorted_date_isi', 'sorted_month_isi']
# rubocop:enable Lint/UselessAssignment

config.add_search_field('date_created') do |field|
field.solr_parameters = {
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/hyrax/content_blocks_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module ContentBlocksControllerDecorator
# override hyrax v2.9.0 added the home_text content block to permitted_params - Adding Themes
def permitted_params
params.require(:content_block).permit(:marketing,
:announcement,
:home_text,
:homepage_about_section_heading,
:homepage_about_section_content,
:researcher)
:announcement,
:home_text,
:homepage_about_section_heading,
:homepage_about_section_content,
:researcher)
end
end
end
Expand Down
19 changes: 9 additions & 10 deletions app/controllers/hyrax/homepage_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
# OVERRIDE Hyrax 3.5 to add content blocks
module Hyrax
module HomepageControllerDecorator

def index
@presenter = presenter_class.new(current_ability, collections)
@featured_researcher = ContentBlock.for(:researcher)
@marketing_text = ContentBlock.for(:marketing)
@featured_work_list = FeaturedWorkList.new
@announcement_text = ContentBlock.for(:announcement)
@homepage_about_section_heading = ContentBlock.for(:homepage_about_section_heading)
@homepage_about_section_content = ContentBlock.for(:homepage_about_section_content)
recent
end
@presenter = presenter_class.new(current_ability, collections)
@featured_researcher = ContentBlock.for(:researcher)
@marketing_text = ContentBlock.for(:marketing)
@featured_work_list = FeaturedWorkList.new
@announcement_text = ContentBlock.for(:announcement)
@homepage_about_section_heading = ContentBlock.for(:homepage_about_section_heading)
@homepage_about_section_content = ContentBlock.for(:homepage_about_section_content)
recent
end
end
end

Expand Down
20 changes: 19 additions & 1 deletion app/models/content_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class ContentBlock < ApplicationRecord
help: :help_page,
terms: :terms_page,
agreement: :agreement_page,
home_text: :home_text
home_text: :home_text,
homepage_about_section_heading: :homepage_about_section_heading,
homepage_about_section_content: :homepage_about_section_content
}.freeze

# NOTE: method defined outside the metaclass wrapper below because
Expand Down Expand Up @@ -90,6 +92,22 @@ def home_text=(value)
home_text.update(value: value)
end

def homepage_about_section_heading
find_or_create_by(name: 'homepage_about_section_heading')
end

def homepage_about_section_heading=(value)
homepage_about_section_heading.update(value: value)
end

def homepage_about_section_content
find_or_create_by(name: 'homepage_about_section_content')
end

def homepage_about_section_content=(value)
homepage_about_section_content.update(value: value)
end

def about_page
find_or_create_by(name: 'about_page')
end
Expand Down
1 change: 0 additions & 1 deletion app/models/generic_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ class GenericWork < ActiveFedora::Base
self.indexer = GenericWorkIndexer

prepend OrderAlready.for(:creator)

end
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def find_ids_by_model(model:, ids: :all)
response_docs.each { |doc| yield doc['id'] }

break if (solr_response['start'] + solr_response['docs'].count) >= solr_response['numFound']
solr_response = ActiveFedora::SolrService.post(solr_query, fl: 'id', rows: @query_rows, start: solr_response['start'] + @query_rows)['response']
solr_response = ActiveFedora::SolrService.post(
solr_query,
fl: 'id',
rows: @query_rows,
start: solr_response['start'] + @query_rows
)['response']
end
end
end
Expand Down

0 comments on commit 880b3d2

Please sign in to comment.