Allow project forums copy.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2976 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-10-25 11:23:46 +00:00
parent 6dfe0395a5
commit 6fedbf60d5
4 changed files with 30 additions and 1 deletions

View File

@ -408,7 +408,7 @@ class Project < ActiveRecord::Base
def copy(project, options={})
project = project.is_a?(Project) ? project : Project.find(project)
to_be_copied = %w(wiki versions issue_categories issues members queries)
to_be_copied = %w(wiki versions issue_categories issues members queries boards)
to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil?
Project.transaction do
@ -522,6 +522,16 @@ class Project < ActiveRecord::Base
end
end
# Copies boards from +project+
def copy_boards(project)
project.boards.each do |board|
new_board = Board.new
new_board.attributes = board.attributes.dup.except("id", "project_id", "topics_count", "messages_count", "last_message_id")
new_board.project = self
self.boards << new_board
end
end
def allowed_permissions
@allowed_permissions ||= begin
module_names = enabled_modules.collect {|m| m.name}

View File

@ -18,6 +18,7 @@
<label class="block"><%= check_box_tag 'only[]', 'issue_categories', true %> <%= l(:label_issue_category_plural) %> (<%= @source_project.issue_categories.count %>)</label>
<label class="block"><%= check_box_tag 'only[]', 'issues', true %> <%= l(:label_issue_plural) %> (<%= @source_project.issues.count %>)</label>
<label class="block"><%= check_box_tag 'only[]', 'queries', true %> <%= l(:label_query_plural) %> (<%= @source_project.queries.count %>)</label>
<label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
<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>
<%= hidden_field_tag 'only[]', '' %>
</fieldset>

View File

@ -17,3 +17,12 @@ boards_002:
position: 2
last_message_id:
messages_count: 0
boards_003:
name: Discussion
project_id: 2
topics_count: 0
id: 3
description: Discussion board
position: 1
last_message_id:
messages_count: 0

View File

@ -488,6 +488,15 @@ class ProjectTest < ActiveSupport::TestCase
end
end
should "copy boards" do
assert @project.copy(@source_project)
assert_equal 1, @project.boards.size
@project.boards.each do |board|
assert !@source_project.boards.include?(board)
end
end
should "change the new issues to use the copied issue categories" do
issue = Issue.find(4)
issue.update_attribute(:category_id, 3)