Sha256: ea1b311aa33aca346d2baf97e5d7b2111e499ee195a96de4a3a3250413063179

Contents?: true

Size: 844 Bytes

Versions: 6

Compression:

Stored size: 844 Bytes

Contents

module Spotlight
  ##
  # Feature pages
  class FeaturePage < Spotlight::Page
    extend FriendlyId
    friendly_id :title, use: [:slugged, :scoped, :finders, :history], scope: :exhibit

    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'

    accepts_nested_attributes_for :child_pages

    belongs_to :thumbnail, class_name: 'Spotlight::FeaturedImage', dependent: :destroy
    accepts_nested_attributes_for :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }

    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

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-spotlight-0.34.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-0.34.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-0.33.3 app/models/spotlight/feature_page.rb
blacklight-spotlight-0.33.2 app/models/spotlight/feature_page.rb
blacklight-spotlight-0.33.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-0.33.0 app/models/spotlight/feature_page.rb