summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-23 18:18:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-23 18:18:13 +0000
commit578fdc62f26c23951b2d2c2b9be0040c7ade0634 (patch)
tree7f78426f78bdc325cae50368cc1bc3e23f4c5eaa /app/models/query.rb
parente1832f25c9aa16f1a95434adc209ee937110228a (diff)
downloadredmine-578fdc62f26c23951b2d2c2b9be0040c7ade0634.tar.gz
redmine-578fdc62f26c23951b2d2c2b9be0040c7ade0634.zip
Ability to assign issues to groups (#2964).
Option is disabled by default. It can be turned on in application settings. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6306 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index 3cb4c4507..28e1a6d18 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -223,15 +223,14 @@ class Query < ActiveRecord::Base
"estimated_hours" => { :type => :float, :order => 13 },
"done_ratio" => { :type => :integer, :order => 14 }}
- user_values = []
- user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
+ principals = []
if project
- user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
+ principals += project.principals.sort
else
all_projects = Project.visible.all
if all_projects.any?
# members of visible projects
- user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort.collect{|s| [s.name, s.id.to_s] }
+ principals += Principal.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort
# project filter
project_values = []
@@ -242,8 +241,17 @@ class Query < ActiveRecord::Base
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
end
end
- @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
- @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
+ users = principals.select {|p| p.is_a?(User)}
+
+ assigned_to_values = []
+ assigned_to_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
+ assigned_to_values += (Setting.issue_group_assignment? ? principals : users).collect{|s| [s.name, s.id.to_s] }
+ @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => assigned_to_values } unless assigned_to_values.empty?
+
+ author_values = []
+ author_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
+ author_values += users.collect{|s| [s.name, s.id.to_s] }
+ @available_filters["author_id"] = { :type => :list, :order => 5, :values => author_values } unless author_values.empty?
group_values = Group.all.collect {|g| [g.name, g.id.to_s] }
@available_filters["member_of_group"] = { :type => :list_optional, :order => 6, :values => group_values } unless group_values.empty?