Class: Spotlight::Resources::UploadController
Instance Method Summary
collapse
Methods included from Controller
#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 21
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
37
38
39
40
41
42
43
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 37
def csv_upload
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_to :back
end
|
#new ⇒ Object
14
15
16
17
18
19
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 14
def new
add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit)
add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
add_breadcrumb t(:'spotlight.resources.upload.new.header'), new_exhibit_resources_upload_path(@exhibit)
end
|
#template ⇒ Object
45
46
47
|
# File 'app/controllers/spotlight/resources/upload_controller.rb', line 45
def template
render text: CSV.generate { |csv| csv << data_param_keys.unshift(:url) }, content_type: 'text/csv'
end
|