From d487069e12d37519db6a96a1fff1292ba03323f3 Mon Sep 17 00:00:00 2001 From: Eduardo Martin Rojo Date: Mon, 29 Jun 2015 12:19:02 +0100 Subject: [PATCH 1/2] Adds support for multiple parents for plate creation. --- app/models/plate/creator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/plate/creator.rb b/app/models/plate/creator.rb index a0bd64f9c2..a8311b07b2 100644 --- a/app/models/plate/creator.rb +++ b/app/models/plate/creator.rb @@ -30,7 +30,7 @@ def can_create_plates?(source_plate, plate_purposes) plate_purposes.include?(r.plate_purpose) end.map(&:parent_purpose).uniq.compact - parent_purposes.empty? || parent_purposes.all? {|p| p==source_plate.purpose} + parent_purposes.empty? || parent_purposes.any? {|p| p==source_plate.purpose} end # Executes the plate creation so that the appropriate child plates are built. @@ -68,7 +68,7 @@ def create_plates(source_plate_barcodes, current_user) def create_child_plates_from(plate, current_user) stock_well_picker = plate.plate_purpose.can_be_considered_a_stock_plate? ? lambda { |w| [w] } : lambda { |w| w.stock_wells } - plate_purposes.map do |target_plate_purpose| + plate_purposes.select{|p| p.parent_purpose==plate.purpose}.map do |target_plate_purpose| target_plate_purpose.target_plate_type.constantize.create_with_barcode!(plate.barcode) do |child_plate| child_plate.plate_purpose = target_plate_purpose child_plate.size = plate.size From 1091a3fc4847b754f7f5b85f65155af25819cf3d Mon Sep 17 00:00:00 2001 From: Eduardo Martin Rojo Date: Mon, 29 Jun 2015 14:13:03 +0100 Subject: [PATCH 2/2] Adds new condition for cherrypicked working dilution plate. Adds plate purpose to the seeds. Adds new test to the features. --- ...0150629112016_add_wd_ch_to_pd_plate_creation.rb | 14 ++++++++++++++ db/schema.rb | 4 ++-- db/seeds/0001_snp_plate_purposes.rb | 10 ++++++++++ features/create_plates.feature | 9 +++++---- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20150629112016_add_wd_ch_to_pd_plate_creation.rb diff --git a/db/migrate/20150629112016_add_wd_ch_to_pd_plate_creation.rb b/db/migrate/20150629112016_add_wd_ch_to_pd_plate_creation.rb new file mode 100644 index 0000000000..c2aba46715 --- /dev/null +++ b/db/migrate/20150629112016_add_wd_ch_to_pd_plate_creation.rb @@ -0,0 +1,14 @@ +class AddWdChToPdPlateCreation < ActiveRecord::Migration + def self.up + ActiveRecord::Base.transaction do + Plate::Creator::PurposeRelationship.create!({ + :plate_creator => Plate::Creator.find_by_name!("Pico Dilution"), + :plate_purpose => Purpose.find_by_name!("Pico Dilution"), + :parent_purpose => Purpose.find_by_name!("Cherrypicked Working Dilution") + }) + end + end + + def self.down + end +end diff --git a/db/schema.rb b/db/schema.rb index b7b93c99ea..3eeac64c48 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,4 @@ -# This file is auto-generated from the current state of the database. Instead of editing this file, +# This file is auto-generated from the current state of the database. Instead of editing this file, # please use the migrations feature of Active Record to incrementally modify your database, and # then regenerate this schema definition. # @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150623152205) do +ActiveRecord::Schema.define(:version => 20150629112016) do create_table "aliquots", :force => true do |t| t.integer "receptacle_id", :null => false diff --git a/db/seeds/0001_snp_plate_purposes.rb b/db/seeds/0001_snp_plate_purposes.rb index 2ae727090d..ef17b1b229 100644 --- a/db/seeds/0001_snp_plate_purposes.rb +++ b/db/seeds/0001_snp_plate_purposes.rb @@ -414,3 +414,13 @@ :asset_shape => Map::AssetShape.find_by_name('Standard'), :barcode_for_tecan => 'ean13_barcode' ) +PlatePurpose.create!( + :name=>'Cherrypicked Working Dilution', + :default_state=>'pending', + :barcode_printer_type=>BarcodePrinterType.find_by_name('96 Well Plate'), + :cherrypickable_target => true, + :cherrypickable_source => false, + :size => 96, + :asset_shape => Map::AssetShape.find_by_name('Standard'), + :barcode_for_tecan => 'ean13_barcode' +) diff --git a/features/create_plates.feature b/features/create_plates.feature index f641a41e29..9c7e689602 100644 --- a/features/create_plates.feature +++ b/features/create_plates.feature @@ -83,10 +83,11 @@ Feature: Printing new plate barcodes And I should be on the new plate page Examples: - | plate_purpose | parent_plate_purpose | - | Working dilution | Stock Plate | - | Pico dilution | Working dilution | - | Pico Assay Plates | Pico dilution | + | plate_purpose | parent_plate_purpose | + | Working dilution | Stock Plate | + | Pico dilution | Working dilution | + | Pico dilution | Cherrypicked Working Dilution | + | Pico Assay Plates | Pico dilution | @xml @qc_event Scenario: Create all QC plates for SLF