diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index 25679b8f7a4a496d84ce409940296d63e0eb1748..8ac8268ef35b8493520614f1a9b30c509c66a48d 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -28,9 +28,9 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro def search @term = params[:term].to_s - @people = current_university.people - .for_search_term(@term) - .ordered + language = Language.find_by(iso_code: params[:lang]) + @people = current_university.people.for_search_term(@term).ordered + @people = @people.joins(:language).where(languages: { iso_code: language.iso_code }) if language.present? end def show diff --git a/app/models/communication/website/page/administrator.rb b/app/models/communication/website/page/administrator.rb index 7e0166f0af0e41de056fa90379192f08b6c97c6d..a58eeadb4b78d366ac353aa8dd132c6be6d75964 100644 --- a/app/models/communication/website/page/administrator.rb +++ b/app/models/communication/website/page/administrator.rb @@ -51,7 +51,7 @@ class Communication::Website::Page::Administrator < Communication::Website::Page def dependencies super + [website.config_default_languages] + - website&.administrators&.map(&:administrator) + website.administrators.where(language_id: language_id).map(&:administrator) end protected diff --git a/app/models/communication/website/page/author.rb b/app/models/communication/website/page/author.rb index 8e8d2ea7d98215ea4607d629f957d5585ba62958..4b3ef3d5822d2534d79c632ff7b75af1fda65edd 100644 --- a/app/models/communication/website/page/author.rb +++ b/app/models/communication/website/page/author.rb @@ -47,7 +47,7 @@ class Communication::Website::Page::Author < Communication::Website::Page def dependencies super + [website.config_default_languages] + - website&.authors&.map(&:author) + website.authors.where(language_id: language_id).map(&:author) end protected diff --git a/app/models/communication/website/page/communication_post.rb b/app/models/communication/website/page/communication_post.rb index cea66d1182a3dd5e059b0752606e3b3fb1b6c90e..873ab16260fdfa2df353b72df08c0e8ead98efc7 100644 --- a/app/models/communication/website/page/communication_post.rb +++ b/app/models/communication/website/page/communication_post.rb @@ -55,8 +55,8 @@ class Communication::Website::Page::CommunicationPost < Communication::Website:: def dependencies super + [website.config_default_languages] + - website.categories + - website.posts + website.categories.where(language_id: language_id) + + website.posts.where(language_id: language_id) end protected diff --git a/app/models/communication/website/page/education_diploma.rb b/app/models/communication/website/page/education_diploma.rb index 43ee5782f4af876c8eb6b2af22623b98ade44f7f..d210fe531cadac646bc7d091bc1f140053d6e219 100644 --- a/app/models/communication/website/page/education_diploma.rb +++ b/app/models/communication/website/page/education_diploma.rb @@ -60,6 +60,7 @@ class Communication::Website::Page::EducationDiploma < Communication::Website::P true end + # TODO: Scope .where(language_id: language_id) when diplomas are translatable def dependencies super + [website.config_default_languages] + diff --git a/app/models/communication/website/page/education_program.rb b/app/models/communication/website/page/education_program.rb index 45de861ba7c60cb0da63523f0878de5c8bbb25e0..9c21eb8fe28631ff9c2c0309eda146eb3d2aa0df 100644 --- a/app/models/communication/website/page/education_program.rb +++ b/app/models/communication/website/page/education_program.rb @@ -60,6 +60,7 @@ class Communication::Website::Page::EducationProgram < Communication::Website::P true end + # TODO: Scope .where(language_id: language_id) when programs are translatable def dependencies super + [website.config_default_languages] + diff --git a/app/models/communication/website/page/organization.rb b/app/models/communication/website/page/organization.rb index 87d1694fb6dfcfe23d7357619429554e6142eb4c..5af8439d12a485c24cee8ffe02feafbfdd3e9105 100644 --- a/app/models/communication/website/page/organization.rb +++ b/app/models/communication/website/page/organization.rb @@ -44,6 +44,7 @@ # class Communication::Website::Page::Organization < Communication::Website::Page + # TODO: Scope .where(language_id: language_id) when organizations are translatable def dependencies super + [website.config_default_languages] + diff --git a/app/models/communication/website/page/person.rb b/app/models/communication/website/page/person.rb index ac27f99614f4c16fdf61b868625357c3165662aa..6a16e8d1b6dc8bbafa3524614773925336957573 100644 --- a/app/models/communication/website/page/person.rb +++ b/app/models/communication/website/page/person.rb @@ -47,12 +47,11 @@ class Communication::Website::Page::Person < Communication::Website::Page def dependencies super + [website.config_default_languages] + - # TODO: @arnaud ça te va ? explicitly_connected_people end def explicitly_connected_people - ids = website.connections.where(indirect_object_type: 'University::Person', direct_source_type: 'Communication::Website::Page::Person').pluck(:indirect_object_id) + ids = website.connections.where(indirect_object_type: 'University::Person', direct_source_type: 'Communication::Website::Page::Person', direct_source_id: self.id).pluck(:indirect_object_id) University::Person.where(id: ids) end diff --git a/app/models/communication/website/page/research_paper.rb b/app/models/communication/website/page/research_paper.rb index b3e3e3396403cdddb1cb477389f5e92b8d051ec6..be477bb28f0299a6557e84b7fc61330e41958c94 100644 --- a/app/models/communication/website/page/research_paper.rb +++ b/app/models/communication/website/page/research_paper.rb @@ -48,6 +48,7 @@ class Communication::Website::Page::ResearchPaper < Communication::Website::Page website.about && website.about&.respond_to?(:papers) end + # TODO: Scope .where(language_id: language_id) when papers are translatable def dependencies super + [website.config_default_languages] + diff --git a/app/models/communication/website/page/research_volume.rb b/app/models/communication/website/page/research_volume.rb index f625016c32a1117c0fb896146e68811370b448b4..e348a1d91891610c883b2851d80909c6f5725b23 100644 --- a/app/models/communication/website/page/research_volume.rb +++ b/app/models/communication/website/page/research_volume.rb @@ -48,6 +48,7 @@ class Communication::Website::Page::ResearchVolume < Communication::Website::Pag website.about && website.about&.respond_to?(:volumes) end + # TODO: Scope .where(language_id: language_id) when volumes are translatable def dependencies super + [website.config_default_languages] + diff --git a/app/models/communication/website/page/researcher.rb b/app/models/communication/website/page/researcher.rb index b8f9a3d1be5ca5d11354cedc814518aec7886112..640edb89dad04af600a9f071a927128faf3973f8 100644 --- a/app/models/communication/website/page/researcher.rb +++ b/app/models/communication/website/page/researcher.rb @@ -51,7 +51,7 @@ class Communication::Website::Page::Researcher < Communication::Website::Page def dependencies super + [website.config_default_languages] + - website.researchers&.map(&:researcher) + website.researchers.where(language_id: language_id).map(&:researcher) end protected diff --git a/app/models/communication/website/page/teacher.rb b/app/models/communication/website/page/teacher.rb index 283d7f9ee20abf0f392fb0842d0da7fb3fe4a3bc..aa07af6dbd960ae71d9461f57dfd7960878317ac 100644 --- a/app/models/communication/website/page/teacher.rb +++ b/app/models/communication/website/page/teacher.rb @@ -51,7 +51,7 @@ class Communication::Website::Page::Teacher < Communication::Website::Page def dependencies super + [website.config_default_languages] + - website.teachers&.map(&:teacher) + website.teachers.where(language_id: language_id).map(&:teacher) end protected diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 0c797db15fd865c79bbc0609e019990dfa4d36d2..a249fbc17b51215982f765b60e259cd64c7d1d19 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -181,7 +181,7 @@ class University::Person < ApplicationRecord end def to_s_with_mail - "#{to_s} (#{email})" + email.present? ? "#{to_s} (#{email})" : to_s end def to_s_alphabetical diff --git a/app/views/admin/communication/extranets/contacts/index.html.erb b/app/views/admin/communication/extranets/contacts/index.html.erb index 117a74808c55b86f7c9a8ad95c8563180425fcf8..1d5c9c26f4d727027b62ff8b71e19afffaa0edaf 100644 --- a/app/views/admin/communication/extranets/contacts/index.html.erb +++ b/app/views/admin/communication/extranets/contacts/index.html.erb @@ -6,7 +6,7 @@ class: button_classes('ms-1') if can?(:show, University::Person) %> <%= osuny_panel University::Person.model_name.human(count: 2), action: action do %> <div class="table-responsive"> - <table class="<%= table_classes%>"> + <table class="<%= table_classes %>"> <tbody> <% @people.each do |person| %> <tr> @@ -25,7 +25,7 @@ class: button_classes('ms-1') if can?(:show, University::Person) %> <%= osuny_panel University::Organization.model_name.human(count: 2), action: action do %> <div class="table-responsive"> - <table class="<%= table_classes%>"> + <table class="<%= table_classes %>"> <tbody> <% @organizations.each do |organization| %> <tr> diff --git a/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb b/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb index 307a28fc0d763ba4a0afc238a51056799920232c..9292423bb3dd199addde2162b44dfc65b95c9e72 100644 --- a/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb +++ b/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb @@ -16,12 +16,12 @@ } %> <% end %> - <table class="<%= table_classes%>"> + <table class="<%= table_classes %>"> <tbody> <% @organizations.each do |organization| %> <tr> <td><%= link_to organization, [:admin, organization] %></td> - <td><%= link_to 'Déconnecter', + <td><%= link_to 'Déconnecter', disconnect_admin_communication_website_page_path(@page, objectId: organization.id, objectType: organization.class), class: button_classes_danger, method: :post %></td> diff --git a/app/views/admin/communication/websites/pages/show/special_pages/_person.html.erb b/app/views/admin/communication/websites/pages/show/special_pages/_person.html.erb index d94258d4b3c7e21433e5a92cce4ebbfb34a45eb0..0c263addfee0e9a659edc838c79bb93bed010ee7 100644 --- a/app/views/admin/communication/websites/pages/show/special_pages/_person.html.erb +++ b/app/views/admin/communication/websites/pages/show/special_pages/_person.html.erb @@ -6,7 +6,7 @@ <%= f.input :name, label: false, as: :autocomplete, - url: search_admin_university_people_path(lang: nil, website_id: nil), + url: search_admin_university_people_path(lang: @page.language.iso_code, website_id: nil), placeholder: t("university.person.search"), input_html: { data: { @@ -16,12 +16,12 @@ } %> <% end %> - <table class="<%= table_classes%>"> + <table class="<%= table_classes %>"> <tbody> <% @people.each do |person| %> <tr> <td><%= link_to person, [:admin, person] %></td> - <td><%= link_to 'Déconnecter', + <td><%= link_to 'Déconnecter', disconnect_admin_communication_website_page_path(@page, objectId: person.id, objectType: person.class), class: button_classes_danger, method: :post %></td>