app/models/spotlight/exhibit.rb in blacklight-spotlight-0.8.0 vs app/models/spotlight/exhibit.rb in blacklight-spotlight-0.8.1
- old
+ new
@@ -5,10 +5,11 @@
class Exhibit < ActiveRecord::Base
include Spotlight::ExhibitAnalytics
include Spotlight::ExhibitDocuments
scope :published, -> { where(published: true) }
+ scope :unpublished, -> { where(published: false) }
extend FriendlyId
friendly_id :title, use: [:slugged, :finders]
validates :title, presence: true
@@ -47,10 +48,11 @@
before_save :sanitize_description, if: :description_changed?
before_create :build_home_page
after_create :initialize_config
after_create :initialize_browse
after_create :initialize_main_navigation
+ include Spotlight::DefaultThumbnailable
scope :published, -> { where(published: true) }
def main_about_page
@main_about_page ||= about_pages.published.first
@@ -81,9 +83,13 @@
Spotlight::Engine.config.upload_fields
end
def searchable?
blacklight_config.search_fields.any? { |_k, v| v.enabled && v.include_in_simple_select != false }
+ end
+
+ def set_default_thumbnail
+ self.thumbnail ||= searches.first.try(:thumbnail)
end
protected
def initialize_config