diff --git a/db/migrations/005_add_material_and_priority_to_parts.rb b/db/migrations/005_add_material_and_priority_to_parts.rb index 1a3772d..30d50f3 100644 --- a/db/migrations/005_add_material_and_priority_to_parts.rb +++ b/db/migrations/005_add_material_and_priority_to_parts.rb @@ -1,10 +1,9 @@ Sequel.migration do change do alter_table(:parts) do - add_column :source_material, String, :null => false - add_column :have_material, Integer, :null => false + add_column :mfg_method, String, :null => false + add_column :finish, String, :null => false add_column :quantity, String, :null => false - add_column :cut_length, String, :null => false add_column :priority, Integer, :null => false add_column :drawing_created, Integer, :null => false end diff --git a/models/.part.rb.swp b/models/.part.rb.swp new file mode 100644 index 0000000..b80a714 Binary files /dev/null and b/models/.part.rb.swp differ diff --git a/models/part.rb b/models/part.rb index 6b1a8ea..2db3d12 100644 --- a/models/part.rb +++ b/models/part.rb @@ -12,19 +12,29 @@ class Part < Sequel::Model # The list of possible part statuses. Key: string stored in database, value: what is displayed to the user. STATUS_MAP = { "designing" => "Design in progress", - "material" => "Material needs to be ordered", +# "material" => "Material needs to be ordered", "ordered" => "Waiting for materials", "drawing" => "Needs drawing", "ready" => "Ready to manufacture", "manufacturing" => "Manufacturing in progress", - "outsourced" => "Waiting for outsourced manufacturing", - "welding" => "Waiting for welding", - "scotchbrite" => "Waiting for Scotch-Brite", - "anodize" => "Ready for anodize", - "powder" => "Ready for powder coating", - "coating" => "Waiting for coating", +# "outsourced" => "Waiting for outsourced manufacturing", +# "welding" => "Waiting for welding", +# "scotchbrite" => "Waiting for Scotch-Brite", +# "anodize" => "Ready for anodize", +# "powder" => "Ready for powder coating", +# "coating" => "Waiting for coating", "assembly" => "Waiting for assembly", "done" => "Done" } + MFG_MAP = { "manual" => "Manual/hand tools", + "milled" => "Milled", + "turned" => "Turned", + "printed" => "3D Printed", + "outsourced" => "Outsourced" } + + FINISH_MAP = { "none" => "None", + "powder_coated" => "Powder coated", + "painted" => "Painted", + "polished" => "Polished" } # Mapping of priority integer stored in database to what is displayed to the user. PRIORITY_MAP = { 0 => "High", 1 => "Normal", 2 => "Low" } diff --git a/parts_server.rb b/parts_server.rb index 0191009..7bfcef4 100644 --- a/parts_server.rb +++ b/parts_server.rb @@ -210,10 +210,9 @@ def send_email(to, subject, body) part = Part.generate_number_and_create(project, params[:type], parent_part) part.name = params[:name].gsub("\"", """) part.status = "designing" - part.source_material = "" - part.have_material = 0 + part.mfg_method = "manual" + part.finish = "none" part.quantity = "" - part.cut_length = "" part.priority = 1 part.drawing_created = 0 part.save @@ -251,10 +250,16 @@ def send_email(to, subject, body) halt(400, "Invalid status.") unless Part::STATUS_MAP.include?(params[:status]) @part.status = params[:status] end + + if params[:mfg_method] + halt(400, "Invalid manufacturing method.") unless Part::MFG_MAP.include?(params[:mfg_method]) + @part.mfg_method = params[:mfg_method] + end + if params[:finish] + halt(400, "Invalid finish type.") unless Part::FINISH_MAP.include?(params[:finish]) + @part.finish = params[:finish] + end @part.notes = params[:notes] if params[:notes] - @part.source_material = params[:source_material] if params[:source_material] - @part.have_material = (params[:have_material] == "on") ? 1 : 0 - @part.cut_length = params[:cut_length] if params[:cut_length] @part.quantity = params[:quantity] if params[:quantity] @part.drawing_created = (params[:drawing_created] == "on") ? 1 : 0 @part.priority = params[:priority] if params[:priority] diff --git a/views/part.erb b/views/part.erb index 9e65592..ec4ecdd 100644 --- a/views/part.erb +++ b/views/part.erb @@ -39,9 +39,8 @@