Class: PlatesFromTubesController

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

Overview

The PlatesFromTubesController handles the creation of plates from tubes. It provides actions to display the form for creating plates and to process the form submission.

The interface for this controller is through the endpoint /plates/from_tubes.

Actions: - new: Renders the form for creating plates from tubes. - create: Processes the form submission and creates plates from the provided tubes.

Before Actions: - set_barcode_printers: Sets the available barcode printers. - set_plate_creators: Sets the available plate creators. - find_plate_creator: Finds the plate creator based on the user's selection. - clear_flashes: Clears any flash messages.

Constants: - VIEW_PATH: The path to the view template for rendering the form.

rubocop:todo Metrics/ClassLength

Constant Summary collapse

VIEW_PATH =
'plates_from_tubes/new'

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



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/plates_from_tubes_controller.rb', line 35

def create
  barcode_printer = BarcodePrinter.find(params[:plates_from_tubes][:barcode_printer])
  scanned_user = User.find_with_barcode_or_swipecard_code(params[:plates_from_tubes][:user_barcode])
  if scanned_user.nil?
    respond_to do |format|
      handle_invalid_user
      format.html { render(VIEW_PATH) }
    end
    return
  end
  transfer_tubes_to_plate(scanned_user, barcode_printer)
end

#newObject



31
32
33
# File 'app/controllers/plates_from_tubes_controller.rb', line 31

def new
  respond_to { |format| format.html { render VIEW_PATH } }
end