mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 06:46:01 +01:00
Let admin users unarchive subprojects of archived projects (#29993).
git-svn-id: http://svn.redmine.org/redmine/trunk@17681 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -393,15 +393,11 @@ class Project < ActiveRecord::Base
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unarchives the project
|
# Unarchives the project and its archived ancestors
|
||||||
# All its ancestors must be active
|
|
||||||
def unarchive
|
def unarchive
|
||||||
return false if ancestors.detect {|a| a.archived?}
|
new_status = ancestors.any?(&:closed?) ? STATUS_CLOSED : STATUS_ACTIVE
|
||||||
new_status = STATUS_ACTIVE
|
self_and_ancestors.status(STATUS_ARCHIVED).update_all :status => new_status
|
||||||
if parent
|
reload
|
||||||
new_status = parent.status
|
|
||||||
end
|
|
||||||
update_attribute :status, new_status
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<td><%= format_date(project.created_on) %></td>
|
<td><%= format_date(project.created_on) %></td>
|
||||||
<td class="buttons">
|
<td class="buttons">
|
||||||
<%= link_to(l(:button_archive), archive_project_path(project, :status => params[:status]), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
<%= link_to(l(:button_archive), archive_project_path(project, :status => params[:status]), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
||||||
<%= link_to(l(:button_unarchive), unarchive_project_path(project, :status => params[:status]), :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
|
<%= link_to(l(:button_unarchive), unarchive_project_path(project, :status => params[:status]), :method => :post, :class => 'icon icon-unlock') if project.archived? %>
|
||||||
<%= link_to(l(:button_copy), copy_project_path(project), :class => 'icon icon-copy') %>
|
<%= link_to(l(:button_copy), copy_project_path(project), :class => 'icon icon-copy') %>
|
||||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -192,18 +192,23 @@ class ProjectTest < ActiveSupport::TestCase
|
|||||||
def test_unarchive
|
def test_unarchive
|
||||||
user = @ecookbook.members.first.user
|
user = @ecookbook.members.first.user
|
||||||
@ecookbook.archive
|
@ecookbook.archive
|
||||||
# A subproject of an archived project can not be unarchived
|
|
||||||
assert !@ecookbook_sub1.unarchive
|
|
||||||
|
|
||||||
# Unarchive project
|
# Unarchive project
|
||||||
assert @ecookbook.unarchive
|
assert @ecookbook.unarchive
|
||||||
@ecookbook.reload
|
|
||||||
assert @ecookbook.active?
|
assert @ecookbook.active?
|
||||||
assert !@ecookbook.archived?
|
assert !@ecookbook.archived?
|
||||||
assert user.projects.include?(@ecookbook)
|
assert user.projects.include?(@ecookbook)
|
||||||
# Subproject can now be unarchived
|
end
|
||||||
|
|
||||||
|
def test_unarchive_child_project_should_unarchive_ancestors
|
||||||
|
@ecookbook.archive
|
||||||
@ecookbook_sub1.reload
|
@ecookbook_sub1.reload
|
||||||
assert @ecookbook_sub1.unarchive
|
assert_equal Project::STATUS_ARCHIVED, @ecookbook_sub1.status
|
||||||
|
|
||||||
|
@ecookbook_sub1.unarchive
|
||||||
|
assert_equal Project::STATUS_ACTIVE, @ecookbook_sub1.status
|
||||||
|
@ecookbook.reload
|
||||||
|
assert_equal Project::STATUS_ACTIVE, @ecookbook.status
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unarchive_a_child_of_a_closed_project_should_set_status_to_closed
|
def test_unarchive_a_child_of_a_closed_project_should_set_status_to_closed
|
||||||
|
|||||||
Reference in New Issue
Block a user