Class: SampleManifestUploadWithTagSequencesController

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

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


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/sample_manifest_upload_with_tag_sequences_controller.rb', line 8

def create
  if params[:upload].present?
    @uploader = SampleManifest::Uploader.new(params[:upload], SampleManifestExcel.configuration, current_user, params[:override])
    if @uploader.valid?
      if @uploader.run!
        flash[:notice] = 'Sample manifest successfully uploaded.'
        redirect_target = (@uploader.study.present? ? sample_manifests_study_path(@uploader.study) : sample_manifests_path)
        redirect_to redirect_target
      else
        flash.now[:error] = 'Your sample manifest couldn\'t be uploaded.'
        prepare_manifest_pagination
        render :new
      end
    else
      flash.now[:error] = 'Your sample manifest couldn\'t be uploaded. See errors below.'
      prepare_manifest_pagination
      render :new
    end
  else
    flash.now[:error] = 'No file attached'
    prepare_manifest_pagination
    render :new
  end
end

#newObject


4
5
6
# File 'app/controllers/sample_manifest_upload_with_tag_sequences_controller.rb', line 4

def new
  prepare_manifest_pagination
end

#prepare_manifest_paginationObject


33
34
35
36
37
38
# File 'app/controllers/sample_manifest_upload_with_tag_sequences_controller.rb', line 33

def prepare_manifest_pagination
  pending_sample_manifests = SampleManifest.pending_manifests.includes(:study, :supplier, :user, :uploaded_document).paginate(page: params[:page])
  completed_sample_manifests = SampleManifest.completed_manifests.includes(:study, :supplier, :user, :uploaded_document).paginate(page: params[:page])
  @display_manifests = pending_sample_manifests | completed_sample_manifests
  @sample_manifests = SampleManifest.paginate(page: params[:page])
end