X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/aa4205482a4af317ec26fc686793b57f02a6864a..281dc29c5c9e3c4c7d0df786df56e46f27541d22:/app/models/user_block.rb diff --git a/app/models/user_block.rb b/app/models/user_block.rb index 8821926bb..cb1a97dca 100644 --- a/app/models/user_block.rb +++ b/app/models/user_block.rb @@ -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