Class: Spotlight::Resources::UploadController

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

Overview

Creating new exhibit items from single-item entry forms or batch CSV upload

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #resource_masthead?, #search_action_url, #search_facet_url, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#createObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 17

def create
  @resource.attributes = resource_params
  @resource.build_upload(image: params[:resources_upload][:url])

  if @resource.save_and_index
    flash[:notice] = t('spotlight.resources.upload.success')
    if params['add-and-continue']
      redirect_to new_exhibit_resource_path(@resource.exhibit, anchor: :new_resources_upload)
    else
      redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
    end
  else
    flash[:error] = t('spotlight.resources.upload.error')
    redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
  end
end