Class: StockStampersController

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

#createObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/stock_stampers_controller.rb', line 7

def create
  @stock_stamper = StockStamper.new(stock_stamper_params)
  if @stock_stamper.valid?
    @stock_stamper.execute
    flash.update(@stock_stamper.message)
    flash.discard
  else
    flash.now[:error] = @stock_stamper.errors.full_messages
    render :new
  end
end

#generate_tecan_fileObject



19
20
21
22
23
24
# File 'app/controllers/stock_stampers_controller.rb', line 19

def generate_tecan_file
  send_data params[:file_content],
            type: 'text/plain',
            filename: "stock_stamper_#{params[:plate_barcode]}.gwl",
            disposition: 'attachment'
end

#newObject



3
4
5
# File 'app/controllers/stock_stampers_controller.rb', line 3

def new
  @stock_stamper = StockStamper.new
end


26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/stock_stampers_controller.rb', line 26

def print_label
  print_job =
    LabelPrinter::PrintJob.new(params[:printer], LabelPrinter::Label::AssetRedirect, printables: params[:printable])
  if print_job.execute
    flash[:notice] = print_job.success
  else
    flash[:error] = print_job.errors.full_messages.join('; ')
  end
  redirect_to new_stock_stamper_path
end

#stock_stamper_paramsObject



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

def stock_stamper_params
  params.require(:stock_stamper).permit(
    :user_barcode,
    :source_plate_barcode,
    :source_plate_type_name,
    :destination_plate_barcode,
    :destination_plate_type_name,
    :overage
  )
end