Class: Spotlight::ExhibitsController
  
  
  
Overview
  
    
Administrative CRUD actions for an exhibit
   
 
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #search_service, #search_service_context
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #enabled_in_spotlight_view_type_configuration?, #field_enabled?
  
  
  
  
  
  
  
  
  
  Methods included from Controller
  #add_breadcrumb, #blacklight_config, #breadcrumbs, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #search_state, #set_exhibit_locale_scope, #set_locale
  
  
  
  
  
  
  
  
  
  Methods included from Config
  #exhibit_specific_blacklight_config
  
  
  
  
    Instance Method Details
    
      
  
  
    #create  ⇒ Object 
  
  
  
  
    
      
56
57
58
59
60
61
62
63
64
65 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 56
def create
  @exhibit.attributes = exhibit_params
  if @exhibit.save
    @exhibit.roles.create user: current_user, role: 'admin' if current_user
    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
     | 
  
 
    
      
  
  
    #destroy  ⇒ Object 
  
  
  
  
    
      
78
79
80
81
82 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 78
def destroy
  @exhibit.destroy
  redirect_to main_app.root_url, notice: t(:'helpers.submit.exhibit.destroyed', model: @exhibit.class.model_name.human.downcase)
end 
     | 
  
 
    
      
  
  
    #edit  ⇒ Object 
  
  
  
  
    
      
49
50
51
52
53
54 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 49
def edit
  add_breadcrumb(t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit)
  add_breadcrumb(t(:'spotlight.configuration.sidebar.header'), exhibit_dashboard_path(@exhibit))
  add_breadcrumb(t(:'spotlight.configuration.sidebar.settings'), edit_exhibit_path(@exhibit))
  build_initial_exhibit_contact_emails
end 
     | 
  
 
    
      
  
  
    #index  ⇒ Object 
  
  
  
  
    
      
13
14
15
16
17
18
19
20
21 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 13
def index
  @published_exhibits = @exhibits.includes(:thumbnail).published.ordered_by_weight.page(params[:page])
  @published_exhibits = @published_exhibits.tagged_with(params[:tag]) if params[:tag]
  if @exhibits.one?
    redirect_to @exhibits.first, flash: flash.to_h
  else
    render layout: 'spotlight/home'
  end
end
     | 
  
 
    
      
  
  
    #new  ⇒ Object 
  
  
  
  
    
      
35
36
37
38
39 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 35
def new
  build_initial_exhibit_contact_emails
  add_breadcrumb(t(:'spotlight.sites.home'), root_url)
  add_breadcrumb(t(:'spotlight.exhibits.new.page_title'))
end 
     | 
  
 
    
      
  
  
    #process_import  ⇒ Object 
  
  
  
  
    
      
41
42
43
44
45
46
47 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 41
def process_import
  if @exhibit.import(JSON.parse(import_exhibit_params.read)) && @exhibit.reindex_later(current_user)
    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
     | 
  
 
    
      
  
  
    #show  ⇒ Object 
  
  
  
  
    
      
23
24
25
26
27
28
29
30
31
32
33 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 23
def show
  respond_to do |format|
    format.json do
      authorize! :export, @exhibit
      send_data JSON.pretty_generate(Spotlight::ExhibitImportExportService.new(@exhibit).as_json),
                type: 'application/json',
                disposition: 'attachment',
                filename: "#{@exhibit.friendly_id}-export.json"
    end
  end
end
     | 
  
 
    
      
  
  
    #update  ⇒ Object 
  
  
  
  
    
      
67
68
69
70
71
72
73
74
75
76 
     | 
    
      # File 'app/controllers/spotlight/exhibits_controller.rb', line 67
def update
  if @exhibit.update(exhibit_params)
    redirect_to edit_exhibit_path(@exhibit, tab: @tab),
                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
     |