Feature #5664 » feature_5664_copy_docs.diff
app/models/project.rb (working copy) | ||
---|---|---|
710 | 710 |
def copy(project, options={}) |
711 | 711 |
project = project.is_a?(Project) ? project : Project.find(project) |
712 | 712 | |
713 |
to_be_copied = %w(wiki versions issue_categories issues members queries boards) |
|
713 |
to_be_copied = %w(wiki versions issue_categories issues members queries boards documents)
|
|
714 | 714 |
to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil? |
715 | 715 | |
716 | 716 |
Project.transaction do |
... | ... | |
959 | 959 |
end |
960 | 960 |
end |
961 | 961 | |
962 |
# Copies documents from +project+ |
|
963 |
def copy_documents(project) |
|
964 |
project.documents.each do |document| |
|
965 |
new_document = Document.new |
|
966 |
new_document.attributes = document.attributes.dup.except("id", "project_id") |
|
967 |
new_document.project = self |
|
968 |
self.documents << new_document |
|
969 |
# Copy attachments to document |
|
970 |
new_document.attachments = document.attachments.map do |attachement| |
|
971 |
attachement.copy(:container => new_document) |
|
972 |
end |
|
973 |
end |
|
974 |
end |
|
975 | ||
962 | 976 |
def allowed_permissions |
963 | 977 |
@allowed_permissions ||= begin |
964 | 978 |
module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name) |
app/views/projects/copy.html.erb (working copy) | ||
---|---|---|
10 | 10 |
<label class="block"><%= check_box_tag 'only[]', 'issues', true %> <%= l(:label_issue_plural) %> (<%= @source_project.issues.count %>)</label> |
11 | 11 |
<label class="block"><%= check_box_tag 'only[]', 'queries', true %> <%= l(:label_query_plural) %> (<%= @source_project.queries.count %>)</label> |
12 | 12 |
<label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label> |
13 |
<label class="block"><%= check_box_tag 'only[]', 'documents', true %> <%= l(:label_document_plural) %> (<%= @source_project.documents.count %>)</label> |
|
13 | 14 |
<label class="block"><%= check_box_tag 'only[]', 'wiki', true %> <%= l(:label_wiki_page_plural) %> (<%= @source_project.wiki.nil? ? 0 : @source_project.wiki.pages.count %>)</label> |
14 | 15 |
<%= hidden_field_tag 'only[]', '' %> |
15 | 16 |
<br /> |