Sha256: 2ebe2ac89fd7019918d45c8882d90e6df7889c8df48bd17f4a7b069807e7b849
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
class Course < ApplicationRecord include Mumuki::Domain::Syncable include Mumuki::Domain::Helpers::Course include Mumuki::Domain::Area validates_presence_of :slug, :shifts, :code, :days, :period, :description, :organization_id validates_uniqueness_of :slug belongs_to :organization has_many :invitations alias_attribute :name, :code resource_fields :slug, :shifts, :code, :days, :period, :description def current_invitation invitations.where('expiration_date > ?', Time.now).take end def import_from_resource_h!(resource_h) update! self.class.slice_resource_h(resource_h) end 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 def invite!(expiration_date) if closed? generate_invitation! expiration_date else current_invitation end end def closed? current_invitation.blank? || current_invitation.expired? end def generate_invitation!(expiration_date) invitation = invitations.build expiration_date: expiration_date, course: self invitation.save_and_notify! end def self.sync_key_id_field :slug end def to_organization organization end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mumuki-domain-7.6.1 | app/models/course.rb |
mumuki-domain-7.6.0 | app/models/course.rb |