summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 5ac166270..d7a3e6ecb 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -22,7 +22,7 @@ class Issue < ActiveRecord::Base
belongs_to :tracker
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
- belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
+ belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
@@ -93,9 +93,11 @@ class Issue < ActiveRecord::Base
when 'all'
nil
when 'default'
- "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
+ user_ids = [user.id] + user.groups.map(&:id)
+ "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids}))"
when 'own'
- "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
+ user_ids = [user.id] + user.groups.map(&:id)
+ "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids}))"
else
'1=0'
end
@@ -109,9 +111,9 @@ class Issue < ActiveRecord::Base
when 'all'
true
when 'default'
- !self.is_private? || self.author == user || self.assigned_to == user
+ !self.is_private? || self.author == user || user.is_or_belongs_to?(assigned_to)
when 'own'
- self.author == user || self.assigned_to == user
+ self.author == user || user.is_or_belongs_to?(assigned_to)
else
false
end
@@ -482,7 +484,13 @@ class Issue < ActiveRecord::Base
# Author and assignee are always notified unless they have been
# locked or don't want to be notified
notified << author if author && author.active? && author.notify_about?(self)
- notified << assigned_to if assigned_to && assigned_to.active? && assigned_to.notify_about?(self)
+ if assigned_to
+ if assigned_to.is_a?(Group)
+ notified += assigned_to.users.select {|u| u.active? && u.notify_about?(self)}
+ else
+ notified << assigned_to if assigned_to.active? && assigned_to.notify_about?(self)
+ end
+ end
notified.uniq!
# Remove users that can not view the issue
notified.reject! {|user| !visible?(user)}