Index: app/models/project.rb
===================================================================
--- app/models/project.rb (revision 12480)
+++ app/models/project.rb (working copy)
@@ -710,7 +710,7 @@
def copy(project, options={})
project = project.is_a?(Project) ? project : Project.find(project)
- to_be_copied = %w(wiki versions issue_categories issues members queries boards)
+ to_be_copied = %w(wiki versions issue_categories issues members queries boards documents)
to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil?
Project.transaction do
@@ -959,6 +959,20 @@
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
+ self.documents << new_document
+ # Copy attachments to document
+ new_document.attachments = document.attachments.map do |attachement|
+ attachement.copy(:container => new_document)
+ end
+ end
+ end
+
def allowed_permissions
@allowed_permissions ||= begin
module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name)
Index: app/views/projects/copy.html.erb
===================================================================
--- app/views/projects/copy.html.erb (revision 12480)
+++ app/views/projects/copy.html.erb (working copy)
@@ -10,6 +10,7 @@
+
<%= hidden_field_tag 'only[]', '' %>