app/models/spotlight/exhibit.rb in blacklight-spotlight-0.13.0 vs app/models/spotlight/exhibit.rb in blacklight-spotlight-0.14.0

- old
+ new

@@ -27,19 +27,20 @@ has_many :custom_fields, dependent: :delete_all has_many :feature_pages, extend: FriendlyId::FinderMethods has_many :main_navigations, dependent: :delete_all has_many :owned_taggings, class_name: 'ActsAsTaggableOn::Tagging', as: :tagger has_many :resources - has_many :roles, dependent: :delete_all + has_many :roles, as: :resource, dependent: :delete_all has_many :searches, dependent: :destroy, extend: FriendlyId::FinderMethods has_many :solr_document_sidecars, dependent: :delete_all has_many :users, through: :roles, class_name: Spotlight::Engine.config.user_class has_many :pages, dependent: :destroy 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 accepts_nested_attributes_for :about_pages, :attachments, :contacts, :custom_fields, :feature_pages, :main_navigations, :owned_taggings, :resources, :searches, :solr_document_sidecars @@ -47,10 +48,11 @@ 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? } before_save :sanitize_description, if: :description_changed? before_create :build_home_page + before_create :add_site_reference after_create :initialize_config after_create :initialize_browse after_create :initialize_main_navigation include Spotlight::DefaultThumbnailable @@ -91,10 +93,22 @@ 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(resources.order('updated_at')) if resources + end + protected + + def add_site_reference + self.site ||= Spotlight::Site.instance + end def initialize_config self.blacklight_configuration ||= Spotlight::BlacklightConfiguration.create! end