summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-20 14:38:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-20 14:38:02 +0000
commit76462d76b59df6f21a465f2aa04e6126493011d3 (patch)
tree08114e73941bc42d3063d0ade87e5cb5ac96be17
parent89ecc003263496a7cf6146ae1cbecb983de4895e (diff)
downloadredmine-76462d76b59df6f21a465f2aa04e6126493011d3.tar.gz
redmine-76462d76b59df6f21a465f2aa04e6126493011d3.zip
Replaces #active_children with nested scopes #descendants.active
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2152 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--nested_projects/app/controllers/reports_controller.rb8
-rw-r--r--nested_projects/app/controllers/search_controller.rb2
-rw-r--r--nested_projects/app/helpers/search_helper.rb2
-rw-r--r--nested_projects/app/models/project.rb4
-rw-r--r--nested_projects/app/models/query.rb6
-rw-r--r--nested_projects/app/views/projects/activity.rhtml2
-rw-r--r--nested_projects/test/unit/project_test.rb2
7 files changed, 11 insertions, 15 deletions
diff --git a/nested_projects/app/controllers/reports_controller.rb b/nested_projects/app/controllers/reports_controller.rb
index dd3ece930..bfe515778 100644
--- a/nested_projects/app/controllers/reports_controller.rb
+++ b/nested_projects/app/controllers/reports_controller.rb
@@ -61,7 +61,7 @@ class ReportsController < ApplicationController
render :template => "reports/issue_report_details"
when "subproject"
@field = "project_id"
- @rows = @project.active_children
+ @rows = @project.descendants.active
@data = issues_by_subproject
@report_title = l(:field_subproject)
render :template => "reports/issue_report_details"
@@ -72,7 +72,7 @@ class ReportsController < ApplicationController
@categories = @project.issue_categories
@assignees = @project.members.collect { |m| m.user }
@authors = @project.members.collect { |m| m.user }
- @subprojects = @project.active_children
+ @subprojects = @project.descendants.active
issues_by_tracker
issues_by_version
issues_by_priority
@@ -229,8 +229,8 @@ private
#{Issue.table_name} i, #{IssueStatus.table_name} s
where
i.status_id=s.id
- and i.project_id IN (#{@project.active_children.collect{|p| p.id}.join(',')})
- group by s.id, s.is_closed, i.project_id") if @project.active_children.any?
+ and i.project_id IN (#{@project.descendants.active.collect{|p| p.id}.join(',')})
+ group by s.id, s.is_closed, i.project_id") if @project.descendants.active.any?
@issues_by_subproject ||= []
end
end
diff --git a/nested_projects/app/controllers/search_controller.rb b/nested_projects/app/controllers/search_controller.rb
index e6e66f05c..485d2349d 100644
--- a/nested_projects/app/controllers/search_controller.rb
+++ b/nested_projects/app/controllers/search_controller.rb
@@ -34,7 +34,7 @@ class SearchController < ApplicationController
when 'my_projects'
User.current.memberships.collect(&:project)
when 'subprojects'
- @project ? ([ @project ] + @project.active_children) : nil
+ @project ? (@project.self_and_descendants.active) : nil
else
@project
end
diff --git a/nested_projects/app/helpers/search_helper.rb b/nested_projects/app/helpers/search_helper.rb
index cd96dbd3f..32ff16f67 100644
--- a/nested_projects/app/helpers/search_helper.rb
+++ b/nested_projects/app/helpers/search_helper.rb
@@ -44,7 +44,7 @@ module SearchHelper
def project_select_tag
options = [[l(:label_project_all), 'all']]
options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty?
- options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.active_children.empty?
+ options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.descendants.active.empty?
options << [@project.name, ''] unless @project.nil?
select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1
end
diff --git a/nested_projects/app/models/project.rb b/nested_projects/app/models/project.rb
index 56929bdf0..c4ea19d96 100644
--- a/nested_projects/app/models/project.rb
+++ b/nested_projects/app/models/project.rb
@@ -203,10 +203,6 @@ class Project < ActiveRecord::Base
end
end
- def active_children
- children.select {|child| child.active?}
- end
-
# Returns an array of the trackers used by the project and its sub projects
def rolled_up_trackers
@rolled_up_trackers ||=
diff --git a/nested_projects/app/models/query.rb b/nested_projects/app/models/query.rb
index 829cda43c..5627dfd5c 100644
--- a/nested_projects/app/models/query.rb
+++ b/nested_projects/app/models/query.rb
@@ -174,8 +174,8 @@ class Query < ActiveRecord::Base
unless @project.versions.empty?
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
end
- unless @project.active_children.empty?
- @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
+ unless @project.descendants.active.empty?
+ @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.active.collect{|s| [s.name, s.id.to_s] } }
end
add_custom_fields_filters(@project.all_issue_custom_fields)
else
@@ -257,7 +257,7 @@ class Query < ActiveRecord::Base
def project_statement
project_clauses = []
- if project && !@project.active_children.empty?
+ if project && !@project.descendants.active.empty?
ids = [project.id]
if has_filter?("subproject_id")
case operator_for("subproject_id")
diff --git a/nested_projects/app/views/projects/activity.rhtml b/nested_projects/app/views/projects/activity.rhtml
index b0e536690..67c991359 100644
--- a/nested_projects/app/views/projects/activity.rhtml
+++ b/nested_projects/app/views/projects/activity.rhtml
@@ -48,7 +48,7 @@
<p><% @activity.event_types.each do |t| %>
<label><%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> <%= l("label_#{t.singularize}_plural")%></label><br />
<% end %></p>
-<% if @project && @project.active_children.any? %>
+<% if @project && @project.descendants.active.any? %>
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
<%= hidden_field_tag 'with_subprojects', 0 %>
<% end %>
diff --git a/nested_projects/test/unit/project_test.rb b/nested_projects/test/unit/project_test.rb
index 3821df698..6a29e96b1 100644
--- a/nested_projects/test/unit/project_test.rb
+++ b/nested_projects/test/unit/project_test.rb
@@ -60,7 +60,7 @@ class ProjectTest < Test::Unit::TestCase
assert !user.projects.include?(@ecookbook)
# Subproject are also archived
assert !@ecookbook.children.empty?
- assert @ecookbook.active_children.empty?
+ assert @ecookbook.descendants.active.empty?
end
def test_unarchive