Class: Spotlight::ExhibitsController

Inherits:
ApplicationController show all
Includes:
Blacklight::SolrHelper
Defined in:
app/controllers/spotlight/exhibits_controller.rb

Instance Method Summary collapse

Methods included from Controller

#blacklight_config, #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



24
25
26
27
28
29
30
31
32
# File 'app/controllers/spotlight/exhibits_controller.rb', line 24

def create
  @exhibit.attributes = exhibit_params

  if @exhibit.save
    redirect_to spotlight.exhibit_dashboard_path(@exhibit), notice: t(:'helpers.submit.exhibit.created', model: @exhibit.class.model_name.human.downcase)
  else
    render action: :new
  end
end

#destroyObject



56
57
58
59
60
# File 'app/controllers/spotlight/exhibits_controller.rb', line 56

def destroy
  @exhibit.destroy

  redirect_to main_app.root_url, notice: t(:'helpers.submit.exhibit.destroyed', model: @exhibit.class.model_name.human.downcase)
end

#editObject



40
41
42
43
44
45
# File 'app/controllers/spotlight/exhibits_controller.rb', line 40

def edit
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
  add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.administration.sidebar.settings'), edit_exhibit_path(@exhibit)
  @exhibit.contact_emails.build unless @exhibit.contact_emails.present?
end

#importObject



10
11
12
13
14
# File 'app/controllers/spotlight/exhibits_controller.rb', line 10

def import
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
  add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.administration.sidebar.import'), import_exhibit_path(@exhibit)
end

#newObject



7
8
# File 'app/controllers/spotlight/exhibits_controller.rb', line 7

def new
end

#process_importObject



16
17
18
19
20
21
22
# File 'app/controllers/spotlight/exhibits_controller.rb', line 16

def process_import
  if @exhibit.import(JSON.parse(import_exhibit_params.read))
    redirect_to spotlight.exhibit_dashboard_path(@exhibit), notice: t(:'helpers.submit.exhibit.updated', model: @exhibit.class.model_name.human.downcase)
  else
    render action: :import
  end
end

#showObject



34
35
36
37
38
# File 'app/controllers/spotlight/exhibits_controller.rb', line 34

def show
  respond_to do |format|
    format.json { send_data Spotlight::ExhibitExportSerializer.new(@exhibit).to_json, type: 'application/json', disposition: 'attachment', filename: "#{@exhibit.friendly_id}-export.json" }
  end
end

#updateObject



47
48
49
50
51
52
53
54
# File 'app/controllers/spotlight/exhibits_controller.rb', line 47

def update
  if @exhibit.update(exhibit_params)
    redirect_to edit_exhibit_path(@exhibit), notice: t(:'helpers.submit.exhibit.updated', model: @exhibit.class.model_name.human.downcase)
  else
    flash[:alert] = @exhibit.errors.full_messages.join("<br>".html_safe)
    render action: :edit
  end
end