mirror of
https://github.com/redmine/redmine.git
synced 2026-03-06 12:31:40 +01:00
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:
@@ -45,16 +45,14 @@ class ProjectsController < ApplicationController
|
||||
|
||||
# Lists visible projects
|
||||
def index
|
||||
projects = Project.find :all,
|
||||
:conditions => Project.visible_by(User.current)
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@project_tree = projects.group_by {|p| p.parent || p}
|
||||
@project_tree.keys.each {|p| @project_tree[p] -= [p]}
|
||||
@projects = Project.visible.find(:all, :order => 'lft')
|
||||
}
|
||||
format.atom {
|
||||
render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i),
|
||||
:title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
||||
projects = Project.visible.find(:all, :order => 'created_on DESC',
|
||||
:limit => Setting.feeds_limit.to_i)
|
||||
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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 :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
|
||||
named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
|
||||
|
||||
def identifier=(identifier)
|
||||
super unless identifier_frozen?
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<h2><%=l(:label_project_plural)%></h2>
|
||||
|
||||
<%= render_project_hierarchy(Project.find(:all, :order => 'lft'))%>
|
||||
<%= render_project_hierarchy(@projects)%>
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<p style="text-align:right;">
|
||||
|
||||
@@ -38,11 +38,18 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:project_tree)
|
||||
# Root project as hash key
|
||||
assert assigns(:project_tree).keys.include?(Project.find(1))
|
||||
# Subproject in corresponding value
|
||||
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
|
||||
assert_not_nil assigns(:projects)
|
||||
|
||||
assert_tag :ul, :child => {:tag => 'li',
|
||||
:descendant => {:tag => 'a', :content => 'eCookbook'},
|
||||
:child => { :tag => 'ul',
|
||||
:descendant => { :tag => 'a',
|
||||
:content => 'Child of private child'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert_no_tag :a, :content => /Private child of eCookbook/
|
||||
end
|
||||
|
||||
def test_index_atom
|
||||
|
||||
Reference in New Issue
Block a user