diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-03 23:03:33 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-03 23:03:33 +0000 |
commit | 33549495c9584878de4c93f3bab010d42cfd97ed (patch) | |
tree | 35cc80d12eafd0860f9d637b9f13a709881e0657 | |
parent | 5dbefbc40dadf5f407ba367cb524307011bd8f84 (diff) | |
download | redmine-33549495c9584878de4c93f3bab010d42cfd97ed.tar.gz redmine-33549495c9584878de4c93f3bab010d42cfd97ed.zip |
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10939 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/project.rb | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 174f63c3a..9f4b07d49 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -695,27 +695,17 @@ class Project < ActiveRecord::Base end end - - # Copies +project+ and returns the new instance. This will not save - # the copy + # Returns a new unsaved Project instance with attributes copied from +project+ def self.copy_from(project) - begin - project = project.is_a?(Project) ? project : Project.find(project) - if project - # clear unique attributes - attributes = project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt') - copy = Project.new(attributes) - copy.enabled_modules = project.enabled_modules - copy.trackers = project.trackers - copy.custom_values = project.custom_values.collect {|v| v.clone} - copy.issue_custom_fields = project.issue_custom_fields - return copy - else - return nil - end - rescue ActiveRecord::RecordNotFound - return nil - end + project = project.is_a?(Project) ? project : Project.find(project) + # clear unique attributes + attributes = project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt') + copy = Project.new(attributes) + copy.enabled_modules = project.enabled_modules + copy.trackers = project.trackers + copy.custom_values = project.custom_values.collect {|v| v.clone} + copy.issue_custom_fields = project.issue_custom_fields + copy end # Yields the given block for each project with its level in the tree |