mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-16 05:58:12 +00:00
All ancestors must be active to unarchive a project.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2155 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
288c9a250a
commit
01ab34d401
@ -165,6 +165,7 @@ class Project < ActiveRecord::Base
|
|||||||
self.status == STATUS_ACTIVE
|
self.status == STATUS_ACTIVE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Archives the project and its descendants recursively
|
||||||
def archive
|
def archive
|
||||||
# Archive subprojects if any
|
# Archive subprojects if any
|
||||||
children.each do |subproject|
|
children.each do |subproject|
|
||||||
@ -173,11 +174,14 @@ class Project < ActiveRecord::Base
|
|||||||
update_attribute :status, STATUS_ARCHIVED
|
update_attribute :status, STATUS_ARCHIVED
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Unarchives the project
|
||||||
|
# All its ancestors must be active
|
||||||
def unarchive
|
def unarchive
|
||||||
return false if parent && !parent.active?
|
return false if ancestors.detect {|a| !a.active?}
|
||||||
update_attribute :status, STATUS_ACTIVE
|
update_attribute :status, STATUS_ACTIVE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an array of projects the project can be moved to
|
||||||
def possible_parents
|
def possible_parents
|
||||||
@possible_parents ||= (Project.active.find(:all) - self_and_descendants)
|
@possible_parents ||= (Project.active.find(:all) - self_and_descendants)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user