From 26b1164cc63e8f1c94910c10ed7e679a32287350 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Fri, 10 Mar 2023 10:40:47 +0100
Subject: [PATCH] fix extranet data

---
 app/models/communication/extranet.rb                 | 12 ++++++++++--
 .../communication/extranet/with_connections.rb       |  4 ++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb
index b187ee1dc..6f227728c 100644
--- a/app/models/communication/extranet.rb
+++ b/app/models/communication/extranet.rb
@@ -104,11 +104,19 @@ class Communication::Extranet < ApplicationRecord
   alias academic_years years
 
   def organizations
-    about&.alumni_organizations || connected_organizations
+    if about.present? && about.respond_to?(:alumni_organizations)
+      about.alumni_organizations
+    else
+      connected_organizations
+    end
   end
 
   def experiences
-    about&.alumni_experiences
+    if about.present? && about.respond_to?(:alumni_experiences)
+      about.alumni_experiences
+    else
+      experiences_through_connections
+    end
   end
 
   def url
diff --git a/app/models/communication/extranet/with_connections.rb b/app/models/communication/extranet/with_connections.rb
index 67841e923..1325bfcec 100644
--- a/app/models/communication/extranet/with_connections.rb
+++ b/app/models/communication/extranet/with_connections.rb
@@ -27,4 +27,8 @@ module Communication::Extranet::WithConnections
     University::Person.where(id: ids)
   end
 
+  def experiences_through_connections
+    University::Person::Experience.where(person_id: connected_persons, organization_id: connected_organizations)
+  end
+
 end
\ No newline at end of file
-- 
GitLab