From 697693cf8f9c9fc0fd7d875562b84f2b70977b93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Wed, 5 Jan 2022 19:05:07 +0100
Subject: [PATCH] fix

---
 app/models/communication/website/with_abouts.rb | 2 +-
 app/models/education/program.rb                 | 3 +++
 app/models/education/program/teacher.rb         | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb
index 610853369..3923523d8 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 35895cbce..195181abe 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 89405ae0d..2a85d5928 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
-- 
GitLab