Newer
Older
#
# id :uuid not null, primary key
# capacity :integer
# continuing :boolean
# ects :integer
# level :integer
# name :string
# slug :string
has_rich_text :accessibility
has_rich_text :contacts
has_rich_text :duration
has_rich_text :evaluation
has_rich_text :objectives
has_rich_text :pedagogy
has_rich_text :prerequisites
has_rich_text :pricing
has_rich_text :registration
belongs_to :parent,
class_name: 'Education::Program',
optional: true
has_many :children,
class_name: 'Education::Program',
foreign_key: :parent_id,
has_and_belongs_to_many :schools,
class_name: 'Education::School',
join_table: 'education_programs_schools',
foreign_key: 'education_program_id',
association_foreign_key: 'education_school_id'
join_table: 'education_programs_teachers',
foreign_key: 'education_program_id',
association_foreign_key: 'education_teacher_id'
bachelor: 300,
master: 500,
doctor: 800
}
validates_presence_of :name
before_validation :make_path
after_save :update_children_paths, if: :saved_change_to_path?
after_save_commit :set_websites_categories, unless: :skip_websites_categories_callback
# Override from WithGithubFiles
def github_path_generated
"_programs/#{path}/index.html".gsub(/\/+/, '/')
end
def make_path
self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/')
end
def list_of_other_programs
university.list_of_programs.reject! { |p| p[:id] == id }
end
def set_websites_categories
websites.find_each(&:set_programs_categories!)
end