Class: Spotlight::BulkUpdatesController

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

Overview

Controller enabling bulk functionality for items defined in a spreadsheet.

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_path, #resource_masthead?, #search_action_url, #search_facet_path, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#download_templateObject



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spotlight/bulk_updates_controller.rb', line 14

def download_template
  # Set Last-Modified as a work-around for https://github.com/rack/rack/issues/1619
  headers['Last-Modified'] = ''
  headers['Cache-Control'] = 'no-cache'
  headers['Content-Type'] = 'text/csv'
  headers['Content-Disposition'] = "attachment; filename=\"#{current_exhibit.slug}-bulk-update-template.csv\""
  headers.delete('Content-Length')

  self.response_body = csv_template
end

#editObject



12
# File 'app/controllers/spotlight/bulk_updates_controller.rb', line 12

def edit; end

#monitorObject



35
36
37
# File 'app/controllers/spotlight/bulk_updates_controller.rb', line 35

def monitor
  render json: BackgroundJobProgress.new(current_exhibit, job_class: Spotlight::ProcessBulkUpdatesCsvJob)
end

#updateObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/spotlight/bulk_updates_controller.rb', line 25

def update
  bulk_update = Spotlight::BulkUpdate.new(exhibit: current_exhibit, file: file_params)
  if bulk_update.save
    ProcessBulkUpdatesCsvJob.perform_later(current_exhibit, bulk_update)
    redirect_back fallback_location: spotlight.edit_exhibit_bulk_updates_path(current_exhibit), notice: t(:'spotlight.bulk_updates.update.submitted')
  else
    redirect_back fallback_location: spotlight.edit_exhibit_bulk_updates_path(current_exhibit), alert: t(:'spotlight.bulk_updates.update.error')
  end
end