diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb index acb9d83..a559b98 100644 --- a/app/helpers/my_helper.rb +++ b/app/helpers/my_helper.rb @@ -33,7 +33,7 @@ module MyHelper def issuesassignedtome_items Issue.visible.open. - where(:assigned_to_id => ([User.current.id] + User.current.group_ids)). + assigned_to(User.current). limit(10). includes(:status, :project, :tracker, :priority). references(:status, :project, :tracker, :priority). diff --git a/app/models/issue.rb b/app/models/issue.rb index 3d57c72..d07041f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -95,6 +95,13 @@ class Issue < ActiveRecord::Base ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v} ids.any? ? where(:fixed_version_id => ids) : where('1=0') } + scope :assigned_to, lambda {|arg| + arg = Array(arg).uniq + ids = arg.map {|p| p.is_a?(Principal) ? p.id : p} + ids += arg.select {|p| p.is_a?(User)}.map(&:group_ids).flatten.uniq + ids.compact! + ids.any? ? where(:assigned_to_id => ids) : none + } before_validation :clear_disabled_fields before_create :default_assign diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c518088..a4d0c4b 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -27,7 +27,7 @@