Class: RobotVerificationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/robot_verifications_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

#downloadObject


23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/robot_verifications_controller.rb', line 23

def download
  if @robot_verification.valid_submission?(params)
    @robot_verification.set_plate_types(params[:source_plate_types])
    @batch = Batch.find(params[:batch_id])
    @batch.robot_verified!(params[:user_id])
    @destination_plate_id = Plate.find_from_barcode(params[:destination_plate_barcodes].keys.first).human_barcode
  else
    flash[:error] = "Error: #{@robot_verification.errors.join('; ')}"
    redirect_to action: :index
  end
end

#get_fields_and_check(barcode_hash) ⇒ Object


35
36
37
38
39
40
# File 'app/controllers/robot_verifications_controller.rb', line 35

def get_fields_and_check(barcode_hash)
  @batch = Batch.find_from_barcode(barcode_hash[:batch_barcode])
  @user = User.find_with_barcode_or_swipecard_code(barcode_hash[:user_barcode])
  @all_labels = @robot_verification.expected_layout(@batch, barcode_hash[:destination_plate_barcode])
  @robot = Robot.find_from_barcode(barcode_hash[:robot_barcode])
end

#indexObject


7
8
# File 'app/controllers/robot_verifications_controller.rb', line 7

def index
end

#new_robot_verificationObject


42
43
44
# File 'app/controllers/robot_verifications_controller.rb', line 42

def new_robot_verification
  @robot_verification = RobotVerification.new
end

#submissionObject


10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/robot_verifications_controller.rb', line 10

def submission
  barcode_hash = params[:barcodes]

  errors = []
  @robot_verification.validate_barcode_params(barcode_hash, &errors.method(:push))
  if errors.empty?
    get_fields_and_check(barcode_hash)
  else
    flash[:error] = errors
    redirect_to action: :index
  end
end