Class: BulkSubmissionsController

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

Constant Summary collapse

DEFAULT_SUBMISSION_TEMPLATE_GROUP =
'General'

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#createObject

rubocop:todo Metrics/MethodLength



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/bulk_submissions_controller.rb', line 25

def create # rubocop:todo Metrics/AbcSize
  @bulk_submission = BulkSubmission.new(params.fetch(:bulk_submission, {}))
  if @bulk_submission.valid?
    flash.now[:notice] = 'File was processed successfully'
    sub_ids, @sub_details = @bulk_submission.completed_submissions
    @these_subs = Submission.find(sub_ids)
  else
    flash.now[:error] = 'There was a problem with your upload'
    render action: 'new'
  end
rescue ActiveRecord::RecordInvalid => e
  flash.now[:error] = 'There was a problem when building your submissions'
  @bulk_submission.errors.add(:base, e.message)
  render action: 'new'
end

#indexObject



15
16
17
# File 'app/controllers/bulk_submissions_controller.rb', line 15

def index
  redirect_to action: 'new'
end

#newObject



19
20
21
22
# File 'app/controllers/bulk_submissions_controller.rb', line 19

def new
  # default action - shows file upload form
  @bulk_submission = BulkSubmission.new
end