diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 8cd7b16e989dc14f708cbf5c8e5114e55d8fb06d..0a8223ff4d9a1449b8d16df3446a2f7e44009083 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -101,27 +101,30 @@ class University::Person < ApplicationRecord def identifiers(website: nil) list = [] - # TODO :administrator - [:author, :researcher, :teacher].each do |role| - list << role if public_send("#{role.to_s}_for_website", website) + [:author, :researcher, :teacher, :administrator].each do |role| + list << role if public_send("is_#{role.to_s}_for_website", website) end list << :static unless list.empty? list end - def author_for_website(website) + def is_author_for_website(website) is_author && communication_website_posts.published.where(communication_website_id: website&.id).any? end - def researcher_for_website(website) + def is_researcher_for_website(website) is_researcher end - def teacher_for_website(website) - # a des formations publiées pour ce website + def is_teacher_for_website(website) is_teacher && website.programs.published.joins(:teachers).where(education_program_teachers: { person_id: id }).any? end + def is_administrator_for_website(website) + # TODO + is_administrative + end + def git_path_static "content/persons/#{slug}.html" end diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index 0bbfffa7de21387fcaecd227f1ab6c70eff0c26e..c6e4a98351f7edf255c7b498f423a1fcc26358fa 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -7,16 +7,16 @@ last_name: "<%= @person.last_name %>" phone: "<%= @person.phone %>" email: "<%= @person.email %>" roles: -<% if @person.is_author %> +<% if @person.is_author_for_website(@website) %> - author <% end %> -<% if @person.is_teacher %> +<% if @person.is_teacher_for_website(@website) %> - teacher <% end %> -<% if @person.is_researcher %> +<% if @person.is_researcher_for_website(@website) %> - researcher <% end %> -<% if @person.is_administrative %> +<% if @person.is_administrator_for_website(@website) %> - administrator <% end %> --- diff --git a/test/fixtures/education/program/role/people.yml b/test/fixtures/education/program/role/people.yml index dd8da3363f801027e36fa69debfde394e349902f..50a25e47a89ea4b3a4cda4a15f37db6331820438 100644 --- a/test/fixtures/education/program/role/people.yml +++ b/test/fixtures/education/program/role/people.yml @@ -19,7 +19,6 @@ # fk_rails_... (person_id => university_people.id) # fk_rails_... (role_id => education_program_roles.id) # -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: position: 1