summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-24 11:31:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-24 11:31:15 +0000
commitc9906480d3f279977720dc3f61534f4a5b77d1d2 (patch)
tree23d1ad1fc0a9435bcb703033dd7b5069ac565005 /app/controllers
parent51b745470c1d71b92072210a008f29c5d5a945d1 (diff)
downloadredmine-c9906480d3f279977720dc3f61534f4a5b77d1d2.tar.gz
redmine-c9906480d3f279977720dc3f61534f4a5b77d1d2.zip
Merged nested projects branch. Removes limit on subproject nesting (#594).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2304 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_controller.rb13
-rw-r--r--app/controllers/projects_controller.rb22
-rw-r--r--app/controllers/reports_controller.rb8
-rw-r--r--app/controllers/search_controller.rb2
-rw-r--r--app/controllers/users_controller.rb2
5 files changed, 16 insertions, 31 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 45a20bf05..61d1eada7 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -26,9 +26,6 @@ class AdminController < ApplicationController
end
def projects
- sort_init 'name', 'asc'
- sort_update %w(name is_public created_on)
-
@status = params[:status] ? params[:status].to_i : 1
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
@@ -37,14 +34,8 @@ class AdminController < ApplicationController
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
end
- @project_count = Project.count(:conditions => c.conditions)
- @project_pages = Paginator.new self, @project_count,
- per_page_option,
- params['page']
- @projects = Project.find :all, :order => sort_clause,
- :conditions => c.conditions,
- :limit => @project_pages.items_per_page,
- :offset => @project_pages.current.offset
+ @projects = Project.find :all, :order => 'lft',
+ :conditions => c.conditions
render :action => "projects", :layout => false if request.xhr?
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2610ca6bc..64040e3ba 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -43,17 +43,14 @@ class ProjectsController < ApplicationController
# Lists visible projects
def index
- projects = Project.find :all,
- :conditions => Project.visible_by(User.current),
- :include => :parent
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
@@ -62,9 +59,6 @@ class ProjectsController < ApplicationController
def add
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.all
- @root_projects = Project.find(:all,
- :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
- :order => 'name')
@project = Project.new(params[:project])
if request.get?
@project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
@@ -74,6 +68,7 @@ class ProjectsController < ApplicationController
else
@project.enabled_module_names = params[:enabled_modules]
if @project.save
+ @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id')
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'admin', :action => 'projects'
end
@@ -88,7 +83,8 @@ class ProjectsController < ApplicationController
end
@members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
- @subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current))
+ @subprojects = @project.children.visible
+ @ancestors = @project.ancestors.visible
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
@trackers = @project.rolled_up_trackers
@@ -110,9 +106,6 @@ class ProjectsController < ApplicationController
end
def settings
- @root_projects = Project.find(:all,
- :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
- :order => 'name')
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@issue_category ||= IssueCategory.new
@member ||= @project.members.new
@@ -126,6 +119,7 @@ class ProjectsController < ApplicationController
if request.post?
@project.attributes = params[:project]
if @project.save
+ @project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id')
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'settings', :id => @project
else
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index dd3ece930..bfe515778 100644
--- a/app/controllers/reports_controller.rb
+++ b/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/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index e6e66f05c..485d2349d 100644
--- a/app/controllers/search_controller.rb
+++ b/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/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 4c9302824..ced17d667 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -83,7 +83,7 @@ class UsersController < ApplicationController
end
@auth_sources = AuthSource.find(:all)
@roles = Role.find_all_givable
- @projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
+ @projects = Project.active.find(:all, :order => 'lft')
@membership ||= Member.new
@memberships = @user.memberships
end