diff --git a/app/assets/stylesheets/admin/appstack.sass b/app/assets/stylesheets/admin/appstack.sass index d0d74497224dd9f304c736654d04bc468b90ae51..f840f4a3c9fb55df1316d459568114c41148bd0c 100644 --- a/app/assets/stylesheets/admin/appstack.sass +++ b/app/assets/stylesheets/admin/appstack.sass @@ -21,3 +21,6 @@ main.content .card-footer .pagination margin-bottom: 0 + +.alert + padding: .95rem diff --git a/app/assets/stylesheets/application/layout.sass b/app/assets/stylesheets/application/layout.sass index 16af462e1104683757ccb592320adfcaa2c7799d..cd015c4d187b46d793493288a6565b52805ad526 100644 --- a/app/assets/stylesheets/application/layout.sass +++ b/app/assets/stylesheets/application/layout.sass @@ -1,4 +1,3 @@ - .alert padding: .95rem &-danger diff --git a/app/controllers/extranet/persons_controller.rb b/app/controllers/extranet/persons_controller.rb index 245f8eb5c9def0dd0129abf876108c90e4b87471..c674dbb34a8bf128ea15ffc8b252c7454f1ba03c 100644 --- a/app/controllers/extranet/persons_controller.rb +++ b/app/controllers/extranet/persons_controller.rb @@ -4,7 +4,7 @@ class Extranet::PersonsController < Extranet::ApplicationController through_association: :people def index - @people = @people.alumni + @people = current_context.about&.alumni || @people.alumni breadcrumb end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 81b225d9a6df452186cbd5020ca79c0993f5a519..3188e41b523405cf3b5d0cca6d27b5b2a266e33a 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -111,6 +111,9 @@ class Education::Program < ApplicationRecord class_name: 'Education::Cohort' has_many :websites, -> { distinct }, through: :schools + has_many :alumni, + through: :cohorts, + source: :people accepts_nested_attributes_for :university_person_involvements, reject_if: :all_blank, allow_destroy: true diff --git a/app/models/education/school.rb b/app/models/education/school.rb index be2ac83e0609728e0bd926a35260c93e8ce789ab..a595593774791ef9fa51b28a9dad9bf499b9980b 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -66,6 +66,9 @@ class Education::School < ApplicationRecord through: :published_programs, source: :university_people_through_role_involvements + has_many :alumni, + through: :programs + validates :name, :address, :city, :zipcode, :country, presence: true scope :ordered, -> { order(:name) } diff --git a/app/models/university/person/alumnus/import.rb b/app/models/university/person/alumnus/import.rb index f7a9ac40350bdbf37f6d575d170109260fcea8dc..96ebaff6016db1743f2fb5d583e3ca643a2c0c23 100644 --- a/app/models/university/person/alumnus/import.rb +++ b/app/models/university/person/alumnus/import.rb @@ -34,7 +34,11 @@ class University::Person::Alumnus::Import < ApplicationRecord if Rails.env.development? # substitute local data for testing substitutes = { - 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '23279cab-8bc1-4c75-bcd8-1fccaa03ad55' + 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '23279cab-8bc1-4c75-bcd8-1fccaa03ad55', # DUT MMI + 'ae3e067a-63b4-4c3f-ba9c-468ade0e4182' => '863b8c9c-1ed1-4af7-b92c-7264dfb6b4da', # MASTER IJBA + 'f4d4a92f-8b8f-4778-a127-9293684666be' => '8dfaee2a-c876-4b1c-8e4e-8380d720c71f', # DU_BILINGUE + '6df53074-195c-4299-8b49-bbc9d7cad41a' => 'be3cb0b2-7f66-4c5f-b8d7-6a39a0480c46', # DU_JRI + '0d81d3a2-a12c-4326-a395-fd0df4a3ea4f' => '56a50383-3ef7-43f6-8e98-daf279e86802' # DUT_JOURNALISME } program_id = substitutes[program_id] if substitutes.has_key? program_id end @@ -59,11 +63,12 @@ class University::Person::Alumnus::Import < ApplicationRecord .first_or_create person.first_name = first_name person.last_name = last_name - else + elsif first_name.present? && last_name.present? person = university.people .where(first_name: first_name, last_name: last_name) .first_or_create end + next unless person # TODO all fields # gender # birth diff --git a/app/views/admin/education/programs/show/_cohorts.html.erb b/app/views/admin/education/programs/show/_cohorts.html.erb index 85fe5fad1f4f9f9189b09582278427d296c96d2b..4e37a2cbba97b81a70d39d89814f39ce23c08f47 100644 --- a/app/views/admin/education/programs/show/_cohorts.html.erb +++ b/app/views/admin/education/programs/show/_cohorts.html.erb @@ -1,6 +1,10 @@ <% if @program.cohorts.any? %> <div class="card flex-fill w-100"> <div class="card-header"> + <div class="float-end"> + <%= @program.alumni.count %> + <%= University::Person::Alumnus.model_name.human(count: 2).downcase %> + </div> <h5 class="card-title mb-0"><%= Education::Cohort.model_name.human(count: 2) %></h5> </div> <table class="<%= table_classes %>"> diff --git a/app/views/admin/education/schools/show.html.erb b/app/views/admin/education/schools/show.html.erb index 273d5439666b07101db04170e1d7933cd4ac6a29..b0d40b059eb49bc8440b3805fe69d7ec14888c19 100644 --- a/app/views/admin/education/schools/show.html.erb +++ b/app/views/admin/education/schools/show.html.erb @@ -32,6 +32,8 @@ <li><%= link_to_if can?(:read, program), program, [:admin, program] %></li> <% end %> </ul> + <%= @school.alumni.count %> + <%= University::Person::Alumnus.model_name.human(count: 2).downcase %> </div> </div> </div> diff --git a/app/views/extranet/persons/show.html.erb b/app/views/extranet/persons/show.html.erb index 93deb12bd5f73983ed6eb7bf00c0b5aa12e7acc6..5af73ffd2762e3029580e51063771d66c06cbbb9 100644 --- a/app/views/extranet/persons/show.html.erb +++ b/app/views/extranet/persons/show.html.erb @@ -35,15 +35,15 @@ <dt><%= cohort.program %></dt> <dd><%= link_to cohort.academic_year, cohort %></dd> <% end %> - <% if @person.phone %> + <% if @person.phone.present? %> <dt><%= University::Person.human_attribute_name(:phone) %></dt> <dd><a href="tel:<%= @person.phone %>" target="_blank" rel="noreferrer"><%= @person.phone %></a></dd> <% end %> - <% if @person.email %> + <% if @person.email.present? %> <dt><%= University::Person.human_attribute_name(:email) %></dt> <dd><a href="mailto:<%= @person.email %>" target="_blank" rel="noreferrer"><%= @person.email %></a></dd> <% end %> - <% if @person.url %> + <% if @person.url.present? %> <dt><%= University::Person.human_attribute_name(:url) %></dt> <dd> <a href="<%= social_website_to_url @person.url %>" target="_blank" rel="noreferrer"> @@ -51,7 +51,7 @@ </a> </dd> <% end %> - <% if @person.linkedin %> + <% if @person.linkedin.present? %> <dt><%= University::Person.human_attribute_name(:linkedin) %></dt> <dd> <a href="<%= social_linkedin_to_url @person.linkedin %>" target="_blank" rel="noreferrer"> @@ -59,7 +59,7 @@ </a> </dd> <% end %> - <% if @person.twitter %> + <% if @person.twitter.present? %> <dt><%= University::Person.human_attribute_name(:twitter) %></dt> <dd> <a href="<%= social_twitter_to_url @person.twitter %>" target="_blank" rel="noreferrer"> diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index 3d19dfc0f0963ec272cc0594e60acbde0cd2f76b..dfec60525b22dab4ca8942bf1f184356b38d2541 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -17,6 +17,9 @@ en: one: School other: Schools attributes: + education/cohort: + year: Year + alumni: Alumni education/program: accessibility: Accessibilité capacity: Capacity diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index d5a940794da9be72ae6c18d98b2179a0098a3a7e..5a6c9dbbd3a1bb2275cd04437155f128002b7509 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -17,6 +17,9 @@ fr: one: École other: Écoles attributes: + education/cohort: + year: Année + alumni: Alumni education/program: accessibility: Accessibilité capacity: Capacité