Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
fixed new part data scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
morops committed Dec 27, 2017
1 parent 5e868bf commit 6ffb7f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions parts_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions views/part.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
</tr>
<tr><td><b>Notes</b></td><td><%= (@part.notes || "").gsub("\n", "<br />") %></td></tr>
<% if @part.type == "part" %>
<tr><td><b>Manufacturing method</b></td><td><%= @part.mfg_method %></td></tr>
<tr><td><b>Finish type</b></td><td><%= @part.finish %></td></tr>
<tr><td><b>Manufacturing method</b></td><td><%= Part::MFG_MAP[@part.mfg_method] %></td></tr>
<tr><td><b>Finish type</b></td><td><%= Part::FINISH_MAP[@part.finish] %></td></tr>
<% end %>
<tr><td><b>Quantity required</b></td><td><%= @part.quantity %></td></tr>
<tr><td><b>Drawing created?</b></td><td><%= (@part.drawing_created == 1) ? "Yes" : "No" %></td></tr>
Expand Down

0 comments on commit 6ffb7f4

Please sign in to comment.