Improve blocks on/by links on user pages
[rails.git] / app / models / user_block.rb
index 8821926bbd3b73a8cb37af6c09dbdd0722326239..2cf0eefc419fd3770c2c339819ac1beb56d1f169 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