Class: BulkSubmissionsController

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

Constant Summary collapse

DEFAULT_SUBMISSION_TEMPLATE_GROUP =
'General'

Instance Method Summary collapse

Methods inherited from ApplicationController

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

Instance Method Details

#createObject


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

def create
  begin
    @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
end

#indexObject


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

def index
  redirect_to action: 'new'
end

#newObject


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

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