about summary refs log tree commit diff
path: root/app/models/invite.rb
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2017-12-02 14:17:11 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2017-12-02 14:17:11 +0000
commit933eafdcd3a3803e9fcf934f6f7ade667281c527 (patch)
tree94f5ab03f7cd733cc0743f3c79cf02a8de4c148f /app/models/invite.rb
parentad46bc9772dfc52c7ed522658eda1a3ef608a7b3 (diff)
parent51f2eca8877d8c56a19e1b8ce4edf407c2d236fb (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'app/models/invite.rb')
-rw-r--r--app/models/invite.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/invite.rb b/app/models/invite.rb
index 7626f4cfa..6907c1f1d 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -17,6 +17,9 @@ class Invite < ApplicationRecord
   belongs_to :user, required: true
   has_many :users, inverse_of: :invite
 
+  scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
+  scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) }
+
   before_validation :set_code
 
   attr_reader :expires_in