diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb index 61085336951158b7738029bdaf3ea375f91a3c95..3923523d890f161aec4176f21ff2f452c0010913 100644 --- a/app/models/communication/website/with_abouts.rb +++ b/app/models/communication/website/with_abouts.rb @@ -42,7 +42,7 @@ module Communication::Website::WithAbouts def people @people ||= ( posts.collect(&:author) + - programs.collect(&:teachers).flatten + programs.collect(&:people).flatten # TODO researchers via articles ).uniq.compact end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 35895cbce50834e5ce0e5da553dac3a61daed813..195181abeb7dd026d9367ce65ea0b4ad575afadd 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -64,6 +64,9 @@ class Education::Program < ApplicationRecord has_many :teachers, class_name: 'Education::Program::Teacher', dependent: :destroy + has_many :people, + through: :teachers, + dependent: :destroy has_and_belongs_to_many :schools, class_name: 'Education::School', join_table: 'education_programs_schools', diff --git a/app/models/education/program/teacher.rb b/app/models/education/program/teacher.rb index 89405ae0d3959ed142125b96103e66e47ff2a411..2a85d592810b94c587411e09d6f8374f22b27d56 100644 --- a/app/models/education/program/teacher.rb +++ b/app/models/education/program/teacher.rb @@ -24,4 +24,10 @@ class Education::Program::Teacher < ApplicationRecord belongs_to :person, class_name: 'University::Person' validates :person_id, uniqueness: { scope: :program_id } + + scope :ordered, -> { joins(:person).order('university_people.last_name, university_people.first_name') } + + def to_s + person.to_s + end end