From 3bacb3dd49cab059fc75774621c9ac40d178fa61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Mon, 9 May 2022 09:42:21 +0200 Subject: [PATCH] cloisonnement --- app/controllers/extranet/persons_controller.rb | 2 +- app/models/education/program.rb | 5 ++++- app/models/education/school.rb | 1 + config/routes/extranet.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/extranet/persons_controller.rb b/app/controllers/extranet/persons_controller.rb index 62ab54dee..b94f7ad99 100644 --- a/app/controllers/extranet/persons_controller.rb +++ b/app/controllers/extranet/persons_controller.rb @@ -1,6 +1,6 @@ class Extranet::PersonsController < Extranet::ApplicationController load_and_authorize_resource class: University::Person::Alumnus, - through: :current_university, + through: :about, through_association: :university_person_alumni def index diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 1a9704e33..b1d2b7e91 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -122,19 +122,22 @@ class Education::Program < ApplicationRecord has_many :alumni, through: :cohorts, source: :people + alias_attribute :university_person_alumni, :alumni has_many :alumni_experiences, -> { distinct }, class_name: 'University::Person::Experience', through: :alumni, source: :experiences - alias_attribute :experiences, :alumni_experiences + alias_attribute :experiences, :alumni_experiences + alias_attribute :university_person_experiences, :alumni_experiences has_many :alumni_organizations, -> { distinct }, class_name: 'University::Organization', through: :alumni_experiences, source: :organization + alias_attribute :university_person_alumni_organizations, :alumni_organizations has_many :education_academic_years, -> { distinct }, diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 5e8aa9457..9335b42b1 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -83,6 +83,7 @@ class Education::School < ApplicationRecord class_name: 'University::Organization', through: :alumni_experiences, source: :organization + alias_attribute :university_person_alumni_organizations, :alumni_organizations has_many :education_academic_years, -> { distinct }, class_name: 'Education::AcademicYear', diff --git a/config/routes/extranet.rb b/config/routes/extranet.rb index 2afd7680e..dfb9725e8 100644 --- a/config/routes/extranet.rb +++ b/config/routes/extranet.rb @@ -1,7 +1,7 @@ get 'cohorts' => 'extranet/cohorts#index', as: :education_cohorts get 'cohorts/:id' => 'extranet/cohorts#show', as: :education_cohort get 'organizations' => 'extranet/organizations#index', as: :university_organizations -get 'organization/:id' => 'extranet/organizations#show', as: :university_organization +get 'organizations/:id' => 'extranet/organizations#show', as: :university_organization get 'persons' => 'extranet/persons#index', as: :university_persons get 'persons/:id' => 'extranet/persons#show', as: :university_person get 'years' => 'extranet/academic_years#index', as: :education_academic_years -- GitLab