Class: Course
Class Method Summary
collapse
Instance Method Summary
collapse
#platform_class_name, #to_param
#platform_class_name, #sync_key
aggregate_of, all_except, defaults, #delete, #destroy!, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, #update_and_notify!, update_or_create!, whitelist_attributes
Class Method Details
.sync_key_id_field ⇒ Object
48
49
50
|
# File 'app/models/course.rb', line 48
def self.sync_key_id_field
:slug
end
|
Instance Method Details
#closed? ⇒ Boolean
39
40
41
|
# File 'app/models/course.rb', line 39
def closed?
current_invitation.blank? || current_invitation.expired?
end
|
#current_invitation ⇒ Object
15
16
17
|
# File 'app/models/course.rb', line 15
def current_invitation
invitations.where('expiration_date > ?', Time.now).take
end
|
#generate_invitation!(expiration_date) ⇒ Object
43
44
45
46
|
# File 'app/models/course.rb', line 43
def generate_invitation!(expiration_date)
invitation = invitations.build expiration_date: expiration_date, course: self
invitation.save_and_notify!
end
|
#import_from_resource_h!(resource_h) ⇒ Object
19
20
21
|
# File 'app/models/course.rb', line 19
def import_from_resource_h!(resource_h)
update! self.class.slice_resource_h(resource_h)
end
|
#invite!(expiration_date) ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/models/course.rb', line 31
def invite!(expiration_date)
if closed?
generate_invitation! expiration_date
else
current_invitation
end
end
|
#slug=(slug) ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/models/course.rb', line 23
def slug=(slug)
s = Mumukit::Auth::Slug.parse(slug)
self[:slug] = slug
self[:code] = s.course
self[:organization_id] = Organization.locate!(s.organization).id
end
|