app/models/spotlight/exhibit.rb in blacklight-spotlight-0.32.0 vs app/models/spotlight/exhibit.rb in blacklight-spotlight-0.33.0

- old
+ new

@@ -15,10 +15,11 @@ extend FriendlyId friendly_id :title, use: [:slugged, :finders] validates :title, presence: true validates :slug, uniqueness: true + validates :theme, inclusion: { in: Spotlight::Engine.config.exhibit_themes }, allow_blank: true acts_as_tagger acts_as_taggable delegate :blacklight_config, to: :blacklight_configuration serialize :facets, Array @@ -44,20 +45,20 @@ has_one :blacklight_configuration, class_name: 'Spotlight::BlacklightConfiguration', dependent: :delete has_one :home_page belongs_to :site belongs_to :masthead, dependent: :destroy - belongs_to :thumbnail, class_name: 'Spotlight::FeaturedImage', dependent: :destroy + belongs_to :thumbnail, class_name: 'Spotlight::ExhibitThumbnail', dependent: :destroy accepts_nested_attributes_for :about_pages, :attachments, :contacts, :custom_fields, :feature_pages, :main_navigations, :owned_taggings, :resources, :searches, :solr_document_sidecars - accepts_nested_attributes_for :blacklight_configuration, :home_page, :masthead, :thumbnail, :filters, update_only: true + accepts_nested_attributes_for :blacklight_configuration, :home_page, :filters, update_only: true + accepts_nested_attributes_for :masthead, :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? } accepts_nested_attributes_for :contact_emails, reject_if: proc { |attr| attr['email'].blank? } accepts_nested_attributes_for :roles, allow_destroy: true, reject_if: proc { |attr| attr['user_key'].blank? && attr['id'].blank? } before_save :sanitize_description, if: :description_changed? - include Spotlight::DefaultThumbnailable def main_about_page @main_about_page ||= about_pages.published.first end @@ -90,28 +91,30 @@ 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 - def requested_by roles.first.user if roles.first end def reindex_progress - @reindex_progress ||= ReindexProgress.new(self) + @reindex_progress ||= ReindexProgress.new(current_reindexing_log_entry) end protected def sanitize_description self.description = ::Rails::Html::FullSanitizer.new.sanitize(description) end def new_reindexing_log_entry(user = nil) Spotlight::ReindexingLogEntry.create(exhibit: self, user: user, items_reindexed_count: 0, job_status: 'unstarted') + end + + private + + def current_reindexing_log_entry + reindexing_log_entries.started_or_completed.first || reindexing_log_entries.build end end end