Sha256: 3a07615d117304295c1849911970b987baccab0d31d2086efae7102a74598cf8
Contents?: true
Size: 1.65 KB
Versions: 5
Compression:
Stored size: 1.65 KB
Contents
# == Schema Information # # Endpoint: # - /v1/org_invites # - /v1/organizations/:organization_id/org_invites # # id :integer not null, primary key # user_id :integer # user_email :string(255) # organization_id :integer # referrer_id :integer # token :string(255) # status :string(255) # created_at :datetime not null # updated_at :datetime not null # user_role :string(255) # team_id :integer # module MnoEnterprise class OrgInvite < BaseResource scope :active, -> { where(status: 'pending') } scope :active_or_staged, -> { where('status.in' => %w(staged pending)) } #============================================================== # Associations #============================================================== belongs_to :user, class_name: 'MnoEnterprise::User' belongs_to :referrer, class_name: 'MnoEnterprise::User' belongs_to :organization, class_name: 'MnoEnterprise::Organization' belongs_to :team, class_name: 'MnoEnterprise::Team' # TODO: specs # Add the user to the organization and update the status of the invite # Add team def accept!(user = self.user) self.put(operation: 'accept', data: { user_id: user.id}) end # TODO: specs def cancel! self.put(operation: 'cancel') end # TODO: specs # Check whether the invite is expired or not def expired? self.status != 'pending' || self.created_at < 3.days.ago end def to_audit_event self.attributes.slice(:team_id, :user_role, :user_email, :user_id, :referrer_id, :organization_id) end end end
Version data entries
5 entries across 5 versions & 1 rubygems