Class: Spotlight::Exhibit

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
ExhibitAnalytics, ExhibitDefaults, ExhibitDocuments, Translatables
Defined in:
app/models/spotlight/exhibit.rb

Overview

Spotlight exhibit

Instance Method Summary collapse

Methods included from ExhibitDocuments

#exhibit_search_builder, #solr_documents

Methods included from ExhibitAnalytics

#analytics, #analytics_provider, #page_analytics

Instance Method Details

#available_localesObject



142
143
144
# File 'app/models/spotlight/exhibit.rb', line 142

def available_locales
  @available_locales ||= languages.pluck(:locale)
end

#browse_categories?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'app/models/spotlight/exhibit.rb', line 93

def browse_categories?
  searches.published.any?
end

#import(hash) ⇒ Object



109
110
111
112
113
114
# File 'app/models/spotlight/exhibit.rb', line 109

def import(hash)
  ActiveRecord::Base.transaction do
    Spotlight::ExhibitImportExportService.new(self).from_hash!(hash)
    save
  end
end

#main_about_pageObject



89
90
91
# File 'app/models/spotlight/exhibit.rb', line 89

def main_about_page
  @main_about_page ||= about_pages.for_locale.published.first
end

#reindex_later(current_user = nil) ⇒ Object



122
123
124
# File 'app/models/spotlight/exhibit.rb', line 122

def reindex_later(current_user = nil)
  Spotlight::ReindexExhibitJob.perform_later(self, user: current_user)
end

#reindex_progressObject



138
139
140
# File 'app/models/spotlight/exhibit.rb', line 138

def reindex_progress
  @reindex_progress ||= BackgroundJobProgress.new(self, job_class: Spotlight::ReindexExhibitJob)
end

#requested_byObject



134
135
136
# File 'app/models/spotlight/exhibit.rb', line 134

def requested_by
  roles.first&.user
end

#searchable?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'app/models/spotlight/exhibit.rb', line 130

def searchable?
  blacklight_config.search_fields.any? { |_k, v| v.enabled && v.include_in_simple_select != false }
end

#solr_dataObject



116
117
118
119
120
# File 'app/models/spotlight/exhibit.rb', line 116

def solr_data
  filters.each_with_object({}) do |filter, hash|
    hash.merge! filter.to_hash
  end
end

#themesObject



97
98
99
100
101
102
103
# File 'app/models/spotlight/exhibit.rb', line 97

def themes
  @themes ||= begin
    return Spotlight::Engine.config.exhibit_themes unless self.class.themes_selector

    self.class.themes_selector.call(self)
  end
end

#to_sObject



105
106
107
# File 'app/models/spotlight/exhibit.rb', line 105

def to_s
  title
end

#uploaded_resource_fieldsObject



126
127
128
# File 'app/models/spotlight/exhibit.rb', line 126

def uploaded_resource_fields
  Spotlight::Engine.config.upload_fields
end