Class: Spotlight::ResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/resources_controller.rb

Overview

CRUD actions for exhibit resources

Instance Method Summary collapse

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#createObject

rubocop:disable Metrics/MethodLength



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/spotlight/resources_controller.rb', line 26

def create
  @resource.attributes = resource_params
  @resource = @resource.becomes_provider

  if @resource.save_and_index
    if from_popup?
      render layout: false, text: '<html><script>window.close();</script></html>'
    else
      redirect_to admin_exhibit_catalog_index_path(@resource.exhibit, sort: :timestamp)
    end
  else
    render action: 'new'
  end
end

#newObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spotlight/resources_controller.rb', line 13

def new
  @resource.attributes = resource_params if params[:resource]
  @resource = @resource.becomes_provider

  ## TODO: in Rails 4.1, replace this with a variant
  if from_popup?
    render layout: 'spotlight/popup'
  else
    render
  end
end

#reindex_allObject

rubocop:enable Metrics/MethodLength



42
43
44
45
46
# File 'app/controllers/spotlight/resources_controller.rb', line 42

def reindex_all
  @exhibit.reindex_later

  redirect_to admin_exhibit_catalog_index_path(@exhibit), notice: t(:'spotlight.resources.reindexing_in_progress')
end