Class: Tasks::Import::Dwca::PsuImportController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/import/dwca/psu_import_controller.rb

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) do_psu_import

POST



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/tasks/import/dwca/psu_import_controller.rb', line 23

def do_psu_import
  if params[:file] && digested_cookie_exists?(params[:file].tempfile, :psu_import_md5)
    @result = BatchLoad::Import::DWCA.new(import_params)
    if @result.create
      flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} rows processed."
      render 'collecting_events/batch_load/simple/create' and return
    else
      flash[:alert] = 'Batch import failed.'
    end
  else
    flash[:alert] = 'File to batch upload must be supplied.'
  end
  render :index
end

- (Object) import_params (private)



39
40
41
# File 'app/controllers/tasks/import/dwca/psu_import_controller.rb', line 39

def import_params
  params.permit(:ce_namespace, :file, :import_level).merge(user_id: sessions_current_user_id, project_id: sessions_current_project_id).symbolize_keys
end

- (Object) index

GET



7
8
# File 'app/controllers/tasks/import/dwca/psu_import_controller.rb', line 7

def index
end

- (Object) preview_psu_import

POST



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/tasks/import/dwca/psu_import_controller.rb', line 11

def preview_psu_import
  if params[:file]
    @result = BatchLoad::Import::DWCA.new(import_params)
    digest_cookie(params[:file].tempfile, :psu_import_md5)
    render 'preview_psu_import'
  else
    flash[:notice] = "No file provided!"
    redirect_to action: :index
  end
end