Class: GelsController

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

Constant Summary

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

#findObject



18
19
# File 'app/controllers/gels_controller.rb', line 18

def find
end

#indexObject



12
13
14
15
16
# File 'app/controllers/gels_controller.rb', line 12

def index
  # TODO: if a plate has a working dilution plate and it has a gel dilution plate, display:
  @gel_plates = GelDilutionPlate.page(params[:page]).order(id: :desc)
  @plates = @gel_plates.filter_map(&:stock_plate)
end

#lookupObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/gels_controller.rb', line 21

def lookup
  @plate = Plate.find_from_barcode([params[:barcode], "#{Plate.default_prefix}#{params[:barcode]}"])
  unless @plate
    flash.now[:error] = 'plate not found'
    render action: :find
    return
  end

  render action: :show
end

#showObject



32
33
34
# File 'app/controllers/gels_controller.rb', line 32

def show
  @plate = Plate.find(params[:id])
end

#updateObject

rubocop:todo Metrics/AbcSize



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

def update # rubocop:todo Metrics/AbcSize
  ActiveRecord::Base.transaction do
    params[:wells].keys.each do |well_id|
      well = Well.find(well_id)
      well.well_attribute.update!(gel_pass: params[:wells][well_id][:qc_state])
      well.events.create_gel_qc!(params[:wells][well_id][:qc_state], current_user)
    end
    Plate.find(params[:id]).events.create_gel_qc!('', current_user)
  end
  flash[:notice] = 'Gel results for plate updated'
  redirect_to action: :index
end