Class: Spotlight::Resources::UploadController
Instance Method Summary
collapse
Methods included from Controller
#blacklight_config, #current_exhibit, #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
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 14
def create
@resource.attributes = resource_params
if @resource.save_and_commit
flash[:notice] = t('spotlight.resources.upload.success')
if params["add-and-continue"]
redirect_to new_exhibit_resources_upload_path(@resource.exhibit)
else
redirect_to admin_exhibit_catalog_index_path(@resource.exhibit, sort: :timestamp)
end
else
flash[:error] = t('spotlight.resources.upload.error')
redirect_to admin_exhibit_catalog_index_path(@resource.exhibit, sort: :timestamp)
end
end
|
#csv_upload ⇒ Object
30
31
32
33
34
35
36
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 30
def csv_upload
file = csv_params[:url]
csv = CSV.parse(file.read, {headers:true, return_headers: false}).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_to :back
end
|
#template ⇒ Object
38
39
40
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 38
def template
render text: CSV.generate { |csv| csv << data_param_keys.unshift(:url) }, content_type: 'text/csv'
end
|