diff options
author | Go MAEDA <maeda@farend.jp> | 2018-04-28 03:45:23 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-04-28 03:45:23 +0000 |
commit | ea562ffa435301a73e0838f2563a6c868799c2a0 (patch) | |
tree | 9e1965c52228289378c16f6cf2a09ae981cfbc03 /app/models/project.rb | |
parent | b1781507617d9386c8545a28941fac163afd50fa (diff) | |
download | redmine-ea562ffa435301a73e0838f2563a6c868799c2a0.tar.gz redmine-ea562ffa435301a73e0838f2563a6c868799c2a0.zip |
Allow to copy documents along with projects (#26621).
Patch by Holger Just.
git-svn-id: http://svn.redmine.org/redmine/trunk@17314 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index dc1709d84..06660adc4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -821,7 +821,7 @@ class Project < ActiveRecord::Base def copy(project, options={}) project = project.is_a?(Project) ? project : Project.find(project) - to_be_copied = %w(members wiki versions issue_categories issues queries boards) + to_be_copied = %w(members wiki versions issue_categories issues queries boards documents) to_be_copied = to_be_copied & Array.wrap(options[:only]) unless options[:only].nil? Project.transaction do @@ -1102,6 +1102,21 @@ class Project < ActiveRecord::Base end end + # Copies documents from +project+ + def copy_documents(project) + project.documents.each do |document| + new_document = Document.new + new_document.attributes = document.attributes.dup.except("id", "project_id") + new_document.project = self + + new_document.attachments = document.attachments.map do |attachement| + attachement.copy(:container => new_document) + end + + self.documents << new_document + end + end + def allowed_permissions @allowed_permissions ||= begin module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name) |