diff --git a/app/controllers/extranet/home_controller.rb b/app/controllers/extranet/home_controller.rb index ec6a69a8ee2e6e746f6314817be13f4884ddc324..6f189dd8b0cff76d40b497875cd8ea06c1b091ed 100644 --- a/app/controllers/extranet/home_controller.rb +++ b/app/controllers/extranet/home_controller.rb @@ -1,7 +1,8 @@ class Extranet::HomeController < Extranet::ApplicationController def index return redirect_to admin_root_path unless current_extranet - @cohorts = current_extranet.about&.cohorts || current_university.education_cohorts - @cohorts = @cohorts.ordered.limit(5) + @about = current_extranet.about || current_university + @cohorts = @about&.cohorts.ordered.limit(5) + @experiences = @about&.experiences.ordered.limit(10) end end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index da883ad4558928482d465a6c194cdcf1b26748cb..ef9465eacc3b327140cc2a88e74bc047f0d8cd9f 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -110,21 +110,27 @@ class Education::Program < ApplicationRecord has_many :websites, -> { distinct }, through: :schools + has_many :cohorts, class_name: 'Education::Cohort' + has_many :alumni, through: :cohorts, source: :people + has_many :alumni_experiences, -> { distinct }, class_name: 'University::Person::Experience', through: :alumni, source: :experiences + alias_attribute :experiences, :alumni_experiences + has_many :alumni_organizations, -> { distinct }, class_name: 'University::Organization', through: :alumni_experiences, source: :organization + has_many :academic_years, through: :cohorts diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 714451661a315ad2be2f6b37dfc7df7ee0f451d3..7149a637cd8a0e01c63cf649c937a507b9114acd 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -74,6 +74,8 @@ class Education::School < ApplicationRecord class_name: 'University::Person::Experience', through: :alumni, source: :experiences + alias_attribute :experiences, :alumni_experiences + has_many :alumni_organizations, -> { distinct }, class_name: 'University::Organization', diff --git a/app/models/university/with_communication.rb b/app/models/university/with_communication.rb index ccf765d5ec5650ef9e4e1b17c7f0806e43a16f26..c43441eb8296b3480d6994078aacc5c6eba5e12e 100644 --- a/app/models/university/with_communication.rb +++ b/app/models/university/with_communication.rb @@ -2,8 +2,19 @@ module University::WithCommunication extend ActiveSupport::Concern included do - has_many :communication_extranets, class_name: 'Communication::Extranet', dependent: :destroy - has_many :communication_websites, class_name: 'Communication::Website', dependent: :destroy - has_many :communication_blocks, class_name: 'Communication::Block', dependent: :destroy + has_many :communication_extranets, + class_name: 'Communication::Extranet', + dependent: :destroy + alias_attribute :extranets, :communication_extranets + + has_many :communication_websites, + class_name: 'Communication::Website', + dependent: :destroy + alias_attribute :websites, :communication_websites + + has_many :communication_blocks, + class_name: 'Communication::Block', + dependent: :destroy + alias_attribute :blocks, :communication_blocks end end diff --git a/app/models/university/with_education.rb b/app/models/university/with_education.rb index eab20006b33a912ae68713ef3a0d3892eb1fa1c8..95b2d605b02dcbfa2fc723b00573f8804211766d 100644 --- a/app/models/university/with_education.rb +++ b/app/models/university/with_education.rb @@ -2,9 +2,24 @@ module University::WithEducation extend ActiveSupport::Concern included do - has_many :education_cohorts, class_name: 'Education::Cohort', dependent: :destroy - has_many :education_programs, class_name: 'Education::Program', dependent: :destroy - has_many :education_schools, class_name: 'Education::School', dependent: :destroy - has_many :academic_years, class_name: 'Education::AcademicYear', dependent: :destroy + has_many :education_cohorts, + class_name: 'Education::Cohort', + dependent: :destroy + alias_attribute :cohorts, :education_cohorts + + has_many :education_programs, + class_name: 'Education::Program', + dependent: :destroy + alias_attribute :programs, :education_programs + + has_many :education_schools, + class_name: 'Education::School', + dependent: :destroy + alias_attribute :schools, :education_schools + + has_many :education_academic_years, + class_name: 'Education::AcademicYear', + dependent: :destroy + alias_attribute :academic_years, :education_academic_years end end diff --git a/app/models/university/with_people_and_organizations.rb b/app/models/university/with_people_and_organizations.rb index ad270f63a8638aaef1549a029877ca523464715c..ad18670f9ec33a65633aeeababacedfa66545254 100644 --- a/app/models/university/with_people_and_organizations.rb +++ b/app/models/university/with_people_and_organizations.rb @@ -2,17 +2,25 @@ module University::WithPeopleAndOrganizations extend ActiveSupport::Concern included do - has_many :people, + has_many :university_people, class_name: 'University::Person', dependent: :destroy - has_many :organizations, + alias_attribute :people, :university_people + + has_many :university_organizations, class_name: 'University::Organization', dependent: :destroy - has_many :organization_imports, + alias_attribute :organizations, :university_organizations + + has_many :university_organization_imports, class_name: 'University::Organization::Import', dependent: :destroy - has_many :person_alumnus_imports, + alias_attribute :organization_imports, :university_organization_imports + + has_many :university_person_alumnus_imports, class_name: 'University::Person::Alumnus::Import', dependent: :destroy + alias_attribute :person_alumnus_imports, :university_person_alumnus_imports + alias_attribute :alumnus_imports, :university_person_alumnus_imports end end diff --git a/app/views/extranet/home/index.html.erb b/app/views/extranet/home/index.html.erb index 3a6a045cbdabf5e569b57de4a9afd5061302f7d7..aa3714a7af09b02bc46eaa44c985e84362a29448 100644 --- a/app/views/extranet/home/index.html.erb +++ b/app/views/extranet/home/index.html.erb @@ -2,7 +2,16 @@ <div class="row"> <div class="col-md-8"> - + <h2>Mouvements récents</h2> + <% @experiences.each do |experience| %> + <article> + <%= link_to experience.person, experience.person %> + <%= experience.description %> + <%= experience.from_year %> + <%= experience.to_year %> + <%= link_to experience.organization, experience.organization %> + </article> + <% end %> </div> <div class="col-md-4"> <h2>Promotions actuelles</h2>