diff options
-rw-r--r-- | app/models/project.rb | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 082e83f55..58346d373 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -34,6 +34,7 @@ class Project < ActiveRecord::Base # Memberships of active users only has_many :members, lambda {joins(:principal).where(:users => {:type => 'User', :status => Principal::STATUS_ACTIVE})} + has_many :users, through: :members has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, lambda {order(:position)} has_many :issues, :dependent => :destroy @@ -625,13 +626,7 @@ class Project < ActiveRecord::Base # Returns the users that should be notified on project events def notified_users - # TODO: User part should be extracted to User#notify_about? - users = - members.preload(:principal).select do |m| - m.principal.present? && - (m.mail_notification? || m.principal.mail_notification == 'all') - end - users.collect {|m| m.principal} + users.where('members.mail_notification = ? OR users.mail_notification = ?', true, 'all') end # Returns a scope of all custom fields enabled for project issues |