]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user_block.rb
Merge branch 'master' into overpass
[rails.git] / app / models / user_block.rb
index 8821926bbd3b73a8cb37af6c09dbdd0722326239..cb1a97dcabfafa8ab5c938dfc408a24174fc8a84 100644 (file)
@@ -9,6 +9,12 @@ class UserBlock < ActiveRecord::Base
 
   PERIODS = USER_BLOCK_PERIODS
 
+  ##
+  # scope to match active blocks
+  def self.active
+    self.where("needs_view or ends_at > ?", Time.now.getutc)
+  end
+
   ##
   # return a renderable version of the reason text.
   def reason
@@ -26,11 +32,11 @@ class UserBlock < ActiveRecord::Base
   # revokes the block, allowing the user to use the API again. the argument
   # is the user object who is revoking the ban.
   def revoke!(revoker)
-    update_attributes({
+    update_attributes(
       :ends_at => Time.now.getutc(),
       :revoker_id => revoker.id,
       :needs_view => false
-    }, :without_protection => true)
+    )
   end
 
 private