Class: StockStampersController

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

#createObject


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

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


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

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

#newObject


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

def new
  @stock_stamper = StockStamper.new
end

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

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


36
37
38
# File 'app/controllers/stock_stampers_controller.rb', line 36

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