diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 247d6682e6acd12b9f58e4366de786c7a027c121..acc1f2dd895d59c7d5de7ae81e64c93e1cb05fec 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -113,6 +113,17 @@ class University::Person < ApplicationRecord "#{first_name} #{last_name}" end + def roles + [:administration, :teacher, :researcher, :alumnus, :author].reject do |role| + ! send "is_#{role}" + end + end + + # TODO denormalize + def is_author + communication_website_posts.any? + end + def websites university.communication_websites end diff --git a/app/views/admin/university/people/_list.html.erb b/app/views/admin/university/people/_list.html.erb index 6218535649f66a8a1b6d70ac749c2b2e49534087..7ad87044b254b5f93adf6ca219eafd4466e5bf20 100644 --- a/app/views/admin/university/people/_list.html.erb +++ b/app/views/admin/university/people/_list.html.erb @@ -3,6 +3,7 @@ <tr> <th><%= University::Person.human_attribute_name('last_name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> + <th><%= University::Person.human_attribute_name('roles') %></th> <th></th> </tr> </thead> @@ -11,6 +12,13 @@ <tr> <td><%= link_to person.last_name, admin_university_person_path(person) %></td> <td><%= link_to person.first_name, admin_university_person_path(person) %></td> + <td> + <% person.roles.each do |role| %> + <span class="badge bg-secondary"> + <%= t "activerecord.attributes.university/person.#{role}" %> + </span> + <% end %> + </td> <td class="text-end"> <div class="btn-group" role="group"> <%= link_to t('edit'), diff --git a/app/views/admin/university/person/alumni/_list.html.erb b/app/views/admin/university/person/alumni/_list.html.erb index 0d3945bd5fcedc5a27458100b0105be9170e19c4..bf9a289c1e349f67ce80813a331507a1cb36ad8a 100644 --- a/app/views/admin/university/person/alumni/_list.html.erb +++ b/app/views/admin/university/person/alumni/_list.html.erb @@ -15,7 +15,7 @@ <td class="text-end"> <div class="btn-group" role="group"> <%= link_to t('edit'), - edit_admin_university_person_alumnus_path(alumnus), + edit_admin_university_person_path(alumnus), class: button_classes if can?(:update, alumnus) %> <%= link_to t('delete'), path, diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index f016ee4c0f939e83dd00abc6aef70f5e103631ef..26e9ee1d95282668b412c266859bba48e2c1eac9 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -31,6 +31,11 @@ fr: is_author: Auteur·rice is_researcher: Chercheur·se is_teacher: Enseignant·e + administration: Personnel administratif + alumnus: Alumnus + author: Auteur·rice + researcher: Chercheur·se + teacher: Enseignant·e last_name: Nom de famille linkedin: LinkedIn (URL) name: Nom