Adds named scopes for projects index.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8082 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-12-04 22:31:02 +00:00
parent f52410be19
commit ff0f141126
4 changed files with 25 additions and 9 deletions
+6 -8
View File
@@ -26,14 +26,12 @@ class AdminController < ApplicationController
end
def projects
@status = params[:status] ? params[:status].to_i : 1
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
unless params[:name].blank?
name = "%#{params[:name].strip.downcase}%"
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
end
@projects = Project.find :all, :order => 'lft',
:conditions => c.conditions
@status = params[:status] || 1
scope = Project.status(@status)
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.all(:order => 'lft')
render :action => "projects", :layout => false if request.xhr?
end