Class: Invitation
Class Method Summary
collapse
Instance Method Summary
collapse
aggregate_of, all_except, defaults, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!
Class Method Details
.find_by_code(code) ⇒ Object
2
3
4
5
6
7
8
9
|
# File 'app/models/invitation.rb', line 2
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
|
.import_from_json!(json) ⇒ Object
11
12
13
|
# File 'app/models/invitation.rb', line 11
def self.import_from_json!(json)
Invitation.create! json
end
|
Instance Method Details
#navigable_name ⇒ Object
19
20
21
|
# File 'app/models/invitation.rb', line 19
def navigable_name
I18n.t(:invitation_for, course: course_name)
end
|
#navigation_end? ⇒ Boolean
23
24
25
|
# File 'app/models/invitation.rb', line 23
def navigation_end?
true
end
|
#organization ⇒ Object
15
16
17
|
# File 'app/models/invitation.rb', line 15
def organization
Organization.find_by! name: course.to_mumukit_slug.organization
end
|
27
28
29
|
# File 'app/models/invitation.rb', line 27
def to_param
code
end
|