Skip to content

Commit

Permalink
add missing methods to avoid content block errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaLMoore committed Sep 21, 2023
1 parent e60efac commit 326576e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/controllers/hyrax/homepage_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# 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
end
end

Hyrax::HomepageController.prepend Hyrax::HomepageControllerDecorator
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

0 comments on commit 326576e

Please sign in to comment.