aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <a3li@gentoo.org>2011-10-14 11:35:57 +0200
committerAlex Legler <a3li@gentoo.org>2011-10-14 11:35:57 +0200
commit8348a227cfb48c0d00a254f1d81b8ea8adac2339 (patch)
treed76e3a1670a5774051b65c50f7a62040c6fcc23e
parentAdd manual exception notification in log_error (diff)
downloadglsamaker-8348a227cfb48c0d00a254f1d81b8ea8adac2339.tar.gz
glsamaker-8348a227cfb48c0d00a254f1d81b8ea8adac2339.tar.bz2
glsamaker-8348a227cfb48c0d00a254f1d81b8ea8adac2339.zip
Don't email disabled users
-rw-r--r--app/models/user.rb3
-rw-r--r--lib/glsamaker/mail.rb4
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 7886bfb..16c66ad 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -34,6 +34,8 @@ class User < ActiveRecord::Base
validates_numericality_of :access, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 3, :message => "Access level must be between 0 and 3"
validates_format_of :email, :with => /[\w.%+-]+?@[\w.-]+?\.\w{2,6}$/, :message => "Invalid Email address format"
+
+ scope :active, where(:disabled => false).where('id > ?', 0)
# Is the user an admin? ;)
def is_el_jefe?
@@ -42,6 +44,7 @@ class User < ActiveRecord::Base
# Checks access to a given GLSA
def can_access?(glsa)
+ return false if disabled?
return false if access == 0 and not glsa.is_owner? self
return false if access < 3 and glsa.restricted
diff --git a/lib/glsamaker/mail.rb b/lib/glsamaker/mail.rb
index d85d690..b749193 100644
--- a/lib/glsamaker/mail.rb
+++ b/lib/glsamaker/mail.rb
@@ -22,7 +22,7 @@ module Glsamaker
return false
end
- User.find(:all, :conditions => 'id > 0').each do |rcpt|
+ User.active.each do |rcpt|
next unless rcpt.can_access? glsa
unless rcpt.get_pref_category(:mail)[:edit] == false
@@ -42,7 +42,7 @@ module Glsamaker
return false
end
- User.find(:all, :conditions => 'id > 0').each do |rcpt|
+ User.active.each do |rcpt|
next unless rcpt.can_access? glsa
unless rcpt.get_pref_category(:mail)[:request] == false