Sha256: 252c48b359143cdf2ef90afac8c3df70ef51c6da933ce63421d3aae192357f81

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Feature pages
  class FeaturePage < Spotlight::Page
    extend FriendlyId
    friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale] do |config|
      config.reserved_words.concat(%w[update_all])
    end

    has_many :child_pages, class_name: 'Spotlight::FeaturePage', inverse_of: :parent_page, foreign_key: 'parent_page_id'
    belongs_to :parent_page, class_name: 'Spotlight::FeaturePage', optional: true

    accepts_nested_attributes_for :child_pages

    belongs_to :thumbnail, class_name: 'Spotlight::FeaturedImage', dependent: :destroy, optional: true

    before_validation unless: :top_level_page? do
      self.exhibit = top_level_page_or_self.exhibit
    end

    def display_sidebar?
      child_pages.published.present? || display_sidebar
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.rc2 app/models/spotlight/feature_page.rb
blacklight-spotlight-3.0.0.rc1 app/models/spotlight/feature_page.rb
blacklight-spotlight-3.0.0.alpha.10 app/models/spotlight/feature_page.rb