Class: QcFilesController

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

Overview

Handles upload, listing and download of qc files. Finds source asset depending of the provided parameters index => Ajaxy rendering of the files attached to a plate/tube/tube_rack show => Retrieve a particular file create => Attach a new file to a plate/tube/tube_rack

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetObject (readonly)

Returns the value of attribute asset.



9
10
11
# File 'app/controllers/qc_files_controller.rb', line 9

def asset
  @asset
end

#asset_pathObject (readonly)

Returns the value of attribute asset_path.



9
10
11
# File 'app/controllers/qc_files_controller.rb', line 9

def asset_path
  @asset_path
end

Instance Method Details

#createObject



23
24
25
26
27
28
29
# File 'app/controllers/qc_files_controller.rb', line 23

def create
  asset.qc_files.create_from_file!(params['qc_file'], params['qc_file'].original_filename)
  redirect_to(
    asset_path,
    notice: 'Your file has been uploaded and is available from the file tab' # rubocop:todo Rails/I18nLocaleTexts
  )
end

#indexObject



13
14
15
# File 'app/controllers/qc_files_controller.rb', line 13

def index
  respond_to { |format| format.json { render json: { 'qc_files' => asset.qc_files } } }
end

#showObject



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

def show
  response = api.qc_file.find(params[:id]).retrieve
  filename = /filename="([^"]*)"/.match(response['Content-Disposition'])[1] || 'unnamed_file'
  send_data(response.body, filename: filename, type: 'sequencescape/qc_file')
end