diff --git a/app/controllers/extranet/academic_years_controller.rb b/app/controllers/extranet/academic_years_controller.rb index bdae2dcb1dc27b5b104e20c7c23cadf46b6cdc4e..ae8af0b8c569df15a51e6a2e3da2f05765b70447 100644 --- a/app/controllers/extranet/academic_years_controller.rb +++ b/app/controllers/extranet/academic_years_controller.rb @@ -9,6 +9,8 @@ class Extranet::AcademicYearsController < Extranet::ApplicationController end def show + @cohorts = @academic_year.cohorts_in_context(current_context.about) + @alumni = @academic_year.alumni_in_context(current_context.about) breadcrumb end diff --git a/app/models/education/academic_year.rb b/app/models/education/academic_year.rb index 2921bc3beba415836e65ed31324ba0f494b9b0b0..42878678e309e949e9123a3fd43c8270ae39c61d 100644 --- a/app/models/education/academic_year.rb +++ b/app/models/education/academic_year.rb @@ -29,12 +29,12 @@ class Education::AcademicYear < ApplicationRecord def cohorts_in_context(context) return cohorts if context.nil? || !context.respond_to?(:cohorts) - cohorts & context.cohorts + cohorts.where(id: context.cohorts.pluck(:id)) end def alumni_in_context(context) return alumni if context.nil? || !context.respond_to?(:alumni) - people & context.alumni + people.where(id: context.alumni.pluck(:id)) end def to_s diff --git a/app/views/extranet/academic_years/show.html.erb b/app/views/extranet/academic_years/show.html.erb index b4db00980201f886b562422faa0a6b85f71bcb44..ffc0c7668f54420022456829f7c12779787b9ca4 100644 --- a/app/views/extranet/academic_years/show.html.erb +++ b/app/views/extranet/academic_years/show.html.erb @@ -5,13 +5,13 @@ </header> <h2 class="mb-4"> - <%= @academic_year.cohorts.count %> - <%= Education::Cohort.model_name.human(count: @academic_year.cohorts.count).downcase %> + <%= @cohorts.count %> + <%= Education::Cohort.model_name.human(count: @cohorts.count).downcase %> </h2> -<%= render 'extranet/cohorts/list', cohorts: @academic_year.cohorts %> +<%= render 'extranet/cohorts/list', cohorts: @cohorts %> <h2 class="mt-5 mb-4"> - <%= @academic_year.people.count %> - <%= University::Person::Alumnus.model_name.human(count: @academic_year.people.count).downcase %> + <%= @alumni.count %> + <%= University::Person::Alumnus.model_name.human(count: @alumni.count).downcase %> </h2> -<%= render 'extranet/persons/list', people: @academic_year.people %> +<%= render 'extranet/persons/list', people: @alumni %>