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

Commit

Permalink
Part upload folder creation/deletion with create/delete of part
Browse files Browse the repository at this point in the history
  • Loading branch information
icecube45 committed Dec 27, 2017
1 parent 6e8ad7f commit 8bf693a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parts_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require "pathological"
require "pony"
require "sinatra/base"

require 'fileutils'
require "models"

module CheesyParts
Expand Down Expand Up @@ -219,6 +219,7 @@ def send_email(to, subject, body)
part.priority = 1
part.drawing_created = 0
part.save
Dir.mkdir "./uploads/#{part.full_part_number}"
redirect "/parts/#{part.id}"
end

Expand Down Expand Up @@ -286,6 +287,7 @@ def send_email(to, subject, body)
project_id = @part.project_id
halt(400, "Invalid part.") if @part.nil?
halt(400, "Can't delete assembly with existing children.") unless @part.child_parts.empty?
FileUtils.rm_rf("./uploads/#{@part.full_part_number}")
@part.delete
params[:referrer] = nil if params[:referrer] =~ /\/parts\/#{params[:id]}$/
redirect params[:referrer] || "/projects/#{project_id}"
Expand Down

0 comments on commit 8bf693a

Please sign in to comment.