From: Sungmin Kim Date: Mon, 27 Jan 2014 11:52:21 +0000 (+0900) Subject: Fixed remove distribution that has dependency projects or jobs. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=968e8e24b25aabf455c8d9e0e86b1a2fe52e3c79;p=sdk%2Ftools%2Fsdk-build.git Fixed remove distribution that has dependency projects or jobs. --- diff --git a/dibs-web/app/controllers/admin_distribution_controller.rb b/dibs-web/app/controllers/admin_distribution_controller.rb index 00b5ad4..10d51ed 100644 --- a/dibs-web/app/controllers/admin_distribution_controller.rb +++ b/dibs-web/app/controllers/admin_distribution_controller.rb @@ -143,6 +143,28 @@ class AdminDistributionController < ApplicationController sync_pkg_svr.destroy end + # remove project + projects = Project.find(:all, :conditions => ["distribution_id = ?", dist.id]) + projects.each do |project| + err = AdminProjectController.remove_project(project.id) + if err then + render :json => { :error => err}, :status => 406 + return + end + end + + # remove job info + jobs = Job.find(:all, :conditions => ["distribution_id = ?", dist.id]) + + if not jobs.nil? then + # remove job_timestamps table + jobs.each do |job| + jobTimestamp = JobTimestamp.delete_all(["job_id=?", job.id]) + job.destroy + end + + end + # remove distribution dist.destroy end diff --git a/dibs-web/app/controllers/admin_project_controller.rb b/dibs-web/app/controllers/admin_project_controller.rb index 14b375a..17a49ca 100644 --- a/dibs-web/app/controllers/admin_project_controller.rb +++ b/dibs-web/app/controllers/admin_project_controller.rb @@ -193,12 +193,20 @@ class AdminProjectController < ApplicationController project_id = change_item[:ProjectId] + err = remove_project(project_id) + if err then + render :json => { :error => err}, :status => 406 + else + render :json => { :success => "OK!" } + end + end + + def AdminProjectController.remove_project(project_id) project = Project.find(:first, :conditions => ["id = ?", project_id]) if project.nil? errmsg = "project does not exist: #{project_id}" - render :json => { :error => errmsg }, :status => 406 - return + return errmsg end # remove job info @@ -244,8 +252,8 @@ class AdminProjectController < ApplicationController # remove project project.destroy - render :json => { :success => "OK!" } - end + return + end def modifyProject change_group_list = params[:ChangeInfoList]