##// END OF EJS Templates
Moved Project#hierarchy to NestedSet::Traversing....
Jean-Philippe Lang -
r13461:ded15dfc802d
parent child
Show More
@@ -696,15 +696,6 class Project < ActiveRecord::Base
696 696 safe_attributes 'inherit_members',
697 697 :if => lambda {|project, user| project.parent.nil? || project.parent.visible?(user)}
698 698
699 # Returns an array of projects that are in this project's hierarchy
700 #
701 # Example: parents, children, siblings
702 def hierarchy
703 parents = project.self_and_ancestors || []
704 descendants = project.descendants || []
705 project_hierarchy = parents | descendants # Set union
706 end
707
708 699 # Returns an auto-generated project identifier based on the last identifier used
709 700 def self.next_identifier
710 701 p = Project.order('id DESC').first
@@ -111,6 +111,14 module Redmine
111 111 def is_or_is_descendant_of?(other)
112 112 other == self || is_descendant_of?(other)
113 113 end
114
115 # Returns the ancestors, the element and its descendants
116 def hierarchy
117 nested_set_scope.where(
118 "#{self.class.table_name}.lft >= :lft AND #{self.class.table_name}.rgt <= :rgt" +
119 " OR #{self.class.table_name}.lft < :lft AND #{self.class.table_name}.rgt > :rgt",
120 {:lft => lft, :rgt => rgt})
121 end
114 122 end
115 123 end
116 124 end
General Comments 0
You need to be logged in to leave comments. Login now