Makes the project list multi-level.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2255 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang committed 2009-01-10 18:06:14 +00:00
1 parent c0e6711826
commit 24441b12e1
4 files changed
+18 -12

No files matched your search

@@ -45,16 +45,14 @@ class ProjectsController < ApplicationController
# Lists visible projects # Lists visible projects
def index def index
projects = Project.find :all,
:conditions => Project.visible_by(User.current)
respond_to do |format| respond_to do |format|
format.html { format.html {
@project_tree = projects.group_by {|p| p.parent || p} @projects = Project.visible.find(:all, :order => 'lft')
@project_tree.keys.each {|p| @project_tree[p] -= [p]}
} }
format.atom { format.atom {
render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i), projects = Project.visible.find(:all, :order => 'created_on DESC',
:title => "#{Setting.app_title}: #{l(:label_project_latest)}") :limit => Setting.feeds_limit.to_i)
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
} }
end end
end end
+1
View File
@@ -67,6 +67,7 @@ class Project < ActiveRecord::Base
named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } } named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"} named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
def identifier=(identifier) def identifier=(identifier)
super unless identifier_frozen? super unless identifier_frozen?
@@ -6,7 +6,7 @@
<h2><%=l(:label_project_plural)%></h2> <h2><%=l(:label_project_plural)%></h2>
<%= render_project_hierarchy(Project.find(:all, :order => 'lft'))%> <%= render_project_hierarchy(@projects)%>
<% if User.current.logged? %> <% if User.current.logged? %>
<p style="text-align:right;"> <p style="text-align:right;">
@@ -38,11 +38,18 @@ class ProjectsControllerTest < Test::Unit::TestCase
get :index get :index
assert_response :success assert_response :success
assert_template 'index' assert_template 'index'
assert_not_nil assigns(:project_tree) assert_not_nil assigns(:projects)
# Root project as hash key
assert assigns(:project_tree).keys.include?(Project.find(1)) assert_tag :ul, :child => {:tag => 'li',
# Subproject in corresponding value :descendant => {:tag => 'a', :content => 'eCookbook'},
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) :child => { :tag => 'ul',
:descendant => { :tag => 'a',
:content => 'Child of private child'
}
}
}
assert_no_tag :a, :content => /Private child of eCookbook/
end end
def test_index_atom def test_index_atom