summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-31 10:39:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-31 10:39:42 +0000
commita1a24483b5c5736704304ca76c9d9a1f8f6ff48c (patch)
tree1033ca43f7b4f9437a2ce0f4251093a56e86358b /app/models
parenta5698b37451357d0037fc50802f2d7f3bbc0dcee (diff)
downloadredmine-a1a24483b5c5736704304ca76c9d9a1f8f6ff48c.tar.gz
redmine-a1a24483b5c5736704304ca76c9d9a1f8f6ff48c.zip
Fixed: deleting a project with subprojects breaks the project tree (#4701).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3354 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 490c290be..b8030d7fd 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -51,7 +51,7 @@ class Project < ActiveRecord::Base
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
:association_foreign_key => 'custom_field_id'
- acts_as_nested_set :order => 'name', :dependent => :destroy
+ acts_as_nested_set :order => 'name'
acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files
@@ -74,7 +74,7 @@ class Project < ActiveRecord::Base
# reserved words
validates_exclusion_of :identifier, :in => %w( new )
- before_destroy :delete_all_members
+ before_destroy :delete_all_members, :destroy_children
named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
@@ -499,6 +499,13 @@ class Project < ActiveRecord::Base
private
+ # Destroys children before destroying self
+ def destroy_children
+ children.each do |child|
+ child.destroy
+ end
+ end
+
# Copies wiki from +project+
def copy_wiki(project)
# Check that the source project has a wiki first