Class: Spotlight::Resources::CsvUploadController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Spotlight::Resources::CsvUploadController
- Defined in:
- app/controllers/spotlight/resources/csv_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, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #redirect_back, #resource_masthead?, #search_action_url, #search_facet_url
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/controllers/spotlight/resources/csv_upload_controller.rb', line 15 def create file = csv_params[:url] csv = CSV.parse(file.read, headers: true, return_headers: false, encoding: 'utf-8').map(&:to_hash) Spotlight::AddUploadsFromCSV.perform_later(csv, current_exhibit, current_user) flash[:notice] = t('spotlight.resources.upload.csv.success', file_name: file.original_filename) redirect_back(fallback_location: spotlight.exhibit_resources_path(current_exhibit)) end |
#template ⇒ Object
23 24 25 |
# File 'app/controllers/spotlight/resources/csv_upload_controller.rb', line 23 def template render plain: CSV.generate { |csv| csv << data_param_keys.unshift(:url) }, content_type: 'text/csv' end |