Sha256: 64f4c396c952eae29323395f3536c686ed7cb6244ec05525a0560f449b044986

Contents?: true

Size: 677 Bytes

Versions: 39

Compression:

Stored size: 677 Bytes

Contents

class Invitation < ApplicationRecord
  def self.find_by_code(code)
    Invitation
      .where(code: code)
      .where(Invitation.arel_table[:expiration_date].gt(Time.now))
      .take!
  rescue RangeError
    raise RecordNotFound.new('The invitation does not exist or it has expired')
  end

  def self.import_from_json!(json)
    Invitation.create! json
  end

  def organization
    Organization.find_by! name: course.to_mumukit_slug.organization
  end

  def navigable_name
    I18n.t(:invitation_for, course: course_name)
  end

  def navigation_end?
    true
  end

  def to_param
    code
  end

  private

  def course_name
    course.to_mumukit_slug.course
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
mumuki-laboratory-5.13.0 app/models/invitation.rb
mumuki-laboratory-5.12.1 app/models/invitation.rb
mumuki-laboratory-5.12.0 app/models/invitation.rb
mumuki-laboratory-5.11.0 app/models/invitation.rb
mumuki-laboratory-5.10.4 app/models/invitation.rb
mumuki-laboratory-5.10.3 app/models/invitation.rb
mumuki-laboratory-5.10.2 app/models/invitation.rb
mumuki-laboratory-5.10.1 app/models/invitation.rb
mumuki-laboratory-5.10.0 app/models/invitation.rb
mumuki-laboratory-5.9.1 app/models/invitation.rb
mumuki-laboratory-5.9.0 app/models/invitation.rb
mumuki-laboratory-5.8.3 app/models/invitation.rb
mumuki-laboratory-5.8.1 app/models/invitation.rb
mumuki-laboratory-5.8.0 app/models/invitation.rb
mumuki-laboratory-5.7.0 app/models/invitation.rb
mumuki-laboratory-5.6.3 app/models/invitation.rb
mumuki-laboratory-5.6.2 app/models/invitation.rb
mumuki-laboratory-5.6.1 app/models/invitation.rb
mumuki-laboratory-5.6.0 app/models/invitation.rb
mumuki-laboratory-5.5.0 app/models/invitation.rb