From bf5db055b43117b692052f5d298733c28bf13e77 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Tue, 7 Mar 2023 10:02:17 +0100 Subject: [PATCH] fix --- .../contacts/organizations_controller.rb | 8 ++++---- .../extranet/contacts/persons_controller.rb | 16 ++++++---------- .../communication/extranet/with_connections.rb | 5 +++++ .../extranet/contacts/organizations/_list.erb | 8 ++++++-- .../extranet/contacts/persons/_person.html.erb | 2 +- .../extranet/contacts/persons/index.html.erb | 17 +++++------------ .../extranet/academic_years_controller_test.rb | 15 --------------- .../alumni/academic_years_controller_test.rb | 15 +++++++++++++++ .../extranet/alumni/cohorts_controller_test.rb | 15 +++++++++++++++ .../organizations_controller_test.rb | 8 ++++---- .../extranet/alumni/persons_controller_test.rb | 15 +++++++++++++++ .../extranet/cohorts_controller_test.rb | 15 --------------- .../extranet/persons_controller_test.rb | 15 --------------- 13 files changed, 76 insertions(+), 78 deletions(-) delete mode 100644 test/controllers/extranet/academic_years_controller_test.rb create mode 100644 test/controllers/extranet/alumni/academic_years_controller_test.rb create mode 100644 test/controllers/extranet/alumni/cohorts_controller_test.rb rename test/controllers/extranet/{ => alumni}/organizations_controller_test.rb (53%) create mode 100644 test/controllers/extranet/alumni/persons_controller_test.rb delete mode 100644 test/controllers/extranet/cohorts_controller_test.rb delete mode 100644 test/controllers/extranet/persons_controller_test.rb diff --git a/app/controllers/extranet/contacts/organizations_controller.rb b/app/controllers/extranet/contacts/organizations_controller.rb index b38c62e41..f2cbefc1a 100644 --- a/app/controllers/extranet/contacts/organizations_controller.rb +++ b/app/controllers/extranet/contacts/organizations_controller.rb @@ -1,9 +1,9 @@ class Extranet::Contacts::OrganizationsController < Extranet::Contacts::ApplicationController def index @organizations = current_extranet.connected_organizations - .ordered - .page(params[:page]) - .per(60) + .ordered + .page(params[:page]) + .per(60) @count = @organizations.total_count breadcrumb end @@ -17,7 +17,7 @@ class Extranet::Contacts::OrganizationsController < Extranet::Contacts::Applicat def breadcrumb super - add_breadcrumb University::Organization.model_name.human(count: 2), alumni_university_organizations_path + add_breadcrumb University::Organization.model_name.human(count: 2), contacts_university_organizations_path add_breadcrumb @organization if @organization end end diff --git a/app/controllers/extranet/contacts/persons_controller.rb b/app/controllers/extranet/contacts/persons_controller.rb index a34a480d3..6ef8e86c3 100644 --- a/app/controllers/extranet/contacts/persons_controller.rb +++ b/app/controllers/extranet/contacts/persons_controller.rb @@ -1,19 +1,15 @@ class Extranet::Contacts::PersonsController < Extranet::Contacts::ApplicationController def index - @facets = University::Person::Alumnus::Facets.new params[:facets], { - model: about&.university_person_alumni.for_language_id(current_university.default_language_id), - about: about - } - @people = @facets.results - .ordered - .page(params[:page]) - .per(60) + @people = current_extranet.connected_persons + .ordered + .page(params[:page]) + .per(60) @count = @people.total_count breadcrumb end def show - @person = about.university_person_alumni.find(params[:id]) + @person = current_extranet.connected_persons.find(params[:id]) breadcrumb end @@ -21,7 +17,7 @@ class Extranet::Contacts::PersonsController < Extranet::Contacts::ApplicationCon def breadcrumb super - add_breadcrumb University::Person.model_name.human(count: 2), alumni_university_persons_path + add_breadcrumb University::Person.model_name.human(count: 2), contacts_university_persons_path add_breadcrumb @person if @person end end diff --git a/app/models/communication/extranet/with_connections.rb b/app/models/communication/extranet/with_connections.rb index 1b2636cbf..67841e923 100644 --- a/app/models/communication/extranet/with_connections.rb +++ b/app/models/communication/extranet/with_connections.rb @@ -22,4 +22,9 @@ module Communication::Extranet::WithConnections University::Organization.where(id: ids) end + def connected_persons + ids = connections.where(object_type: 'University::Person').pluck(:object_id) + University::Person.where(id: ids) + end + end \ No newline at end of file diff --git a/app/views/extranet/contacts/organizations/_list.erb b/app/views/extranet/contacts/organizations/_list.erb index 616693575..6c8592c60 100644 --- a/app/views/extranet/contacts/organizations/_list.erb +++ b/app/views/extranet/contacts/organizations/_list.erb @@ -1,8 +1,12 @@ <div class="row"> <% @organizations.each do |organization| %> <div class="col-md-3"> - <%= kamifusen_tag organization.logo, width: 400, class: 'img-fluid' if organization.logo.attached? %> - <p class="mb-0"><%= link_to organization, [:contacts, organization], class: 'stretched-link' %></p> + <div class="card"> + <%= kamifusen_tag organization.logo, width: 400, class: 'img-fluid p-5' if organization.logo.attached? %> + <div class="card-body text-center"> + <%= link_to organization, [:contacts, organization], class: 'stretched-link' %> + </div> + </div> </div> <% end %> </div> diff --git a/app/views/extranet/contacts/persons/_person.html.erb b/app/views/extranet/contacts/persons/_person.html.erb index 21b681748..5800edb49 100644 --- a/app/views/extranet/contacts/persons/_person.html.erb +++ b/app/views/extranet/contacts/persons/_person.html.erb @@ -12,7 +12,7 @@ <% end %> </div> <div class="col-9 col-md-12"> - <%= link_to [:alumni, person], class: 'stretched-link' do %> + <%= link_to [:contacts, person], class: 'stretched-link' do %> <%= person.first_name %> <%= person.last_name %> <% end %> </div> diff --git a/app/views/extranet/contacts/persons/index.html.erb b/app/views/extranet/contacts/persons/index.html.erb index ea22d1b37..36bd5fac0 100644 --- a/app/views/extranet/contacts/persons/index.html.erb +++ b/app/views/extranet/contacts/persons/index.html.erb @@ -5,17 +5,10 @@ <% end %> <div class="row"> - <div class="col-lg-3"> - <%= render 'faceted_search/facets', facets: @facets %> - </div> - <div class="offset-lg-1 col-lg-8"> - <div class="row"> - <% @people.each do |person| %> - <div class="col-xxl-3 col-md-4 col-sm-6"> - <%= render 'extranet/alumni/persons/person', person: person %> - </div> - <% end %> + <% @people.each do |person| %> + <div class="col-xxl-2 col-md-3 col-sm-6"> + <%= render 'extranet/contacts/persons/person', person: person %> </div> - <%= paginate @people, theme: 'bootstrap-5', window: 2 %> - </div> + <% end %> </div> +<%= paginate @people, theme: 'bootstrap-5', window: 2 %> diff --git a/test/controllers/extranet/academic_years_controller_test.rb b/test/controllers/extranet/academic_years_controller_test.rb deleted file mode 100644 index f4b820116..000000000 --- a/test/controllers/extranet/academic_years_controller_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test_helper" - -class Extranet::AcademicYearsControllerTest < ActionDispatch::IntegrationTest - include ExtranetSetup - - def test_index - get education_academic_years_path - assert_response(:success) - end - - def test_show - get education_academic_year_path(education_academic_years(:twenty_two)) - assert_response(:success) - end -end diff --git a/test/controllers/extranet/alumni/academic_years_controller_test.rb b/test/controllers/extranet/alumni/academic_years_controller_test.rb new file mode 100644 index 000000000..218be5b5e --- /dev/null +++ b/test/controllers/extranet/alumni/academic_years_controller_test.rb @@ -0,0 +1,15 @@ +require "test_helper" + +class Extranet::Alumni::AcademicYearsControllerTest < ActionDispatch::IntegrationTest + include ExtranetSetup + + def test_index + get alumni_education_academic_years_path + assert_response(:success) + end + + def test_show + get alumni_education_academic_year_path(education_academic_years(:twenty_two)) + assert_response(:success) + end +end diff --git a/test/controllers/extranet/alumni/cohorts_controller_test.rb b/test/controllers/extranet/alumni/cohorts_controller_test.rb new file mode 100644 index 000000000..be957ebc3 --- /dev/null +++ b/test/controllers/extranet/alumni/cohorts_controller_test.rb @@ -0,0 +1,15 @@ +require "test_helper" + +class Extranet::Alumni::CohortsControllerTest < ActionDispatch::IntegrationTest + include ExtranetSetup + + def test_index + get alumni_education_cohorts_path + assert_response(:success) + end + + def test_show + get alumni_education_cohort_path(education_cohorts(:default_cohort)) + assert_response(:success) + end +end diff --git a/test/controllers/extranet/organizations_controller_test.rb b/test/controllers/extranet/alumni/organizations_controller_test.rb similarity index 53% rename from test/controllers/extranet/organizations_controller_test.rb rename to test/controllers/extranet/alumni/organizations_controller_test.rb index 5e3edacef..4ae389477 100644 --- a/test/controllers/extranet/organizations_controller_test.rb +++ b/test/controllers/extranet/alumni/organizations_controller_test.rb @@ -1,15 +1,15 @@ require "test_helper" -class Extranet::OrganizationsControllerTest < ActionDispatch::IntegrationTest +class Extranet::Alumni::OrganizationsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_index - get university_organizations_path + get alumni_university_organizations_path assert_response(:success) end def test_search - get search_university_organizations_path(term: "Organisation de test") + get alumni_search_university_organizations_path(term: "Organisation de test") assert_response(:success) results = JSON.parse(response.body) assert_equal(1, results.size) @@ -17,7 +17,7 @@ class Extranet::OrganizationsControllerTest < ActionDispatch::IntegrationTest end def test_show - get university_organization_path(university_organizations(:default_organization)) + get alumni_university_organization_path(university_organizations(:default_organization)) assert_response(:success) end end diff --git a/test/controllers/extranet/alumni/persons_controller_test.rb b/test/controllers/extranet/alumni/persons_controller_test.rb new file mode 100644 index 000000000..d8fd71dd7 --- /dev/null +++ b/test/controllers/extranet/alumni/persons_controller_test.rb @@ -0,0 +1,15 @@ +require "test_helper" + +class Extranet::Alumni::PersonsControllerTest < ActionDispatch::IntegrationTest + include ExtranetSetup + + def test_index + get alumni_university_persons_path + assert_response(:success) + end + + def test_show + get alumni_university_person_path(university_people(:alumnus)) + assert_response(:success) + end +end diff --git a/test/controllers/extranet/cohorts_controller_test.rb b/test/controllers/extranet/cohorts_controller_test.rb deleted file mode 100644 index f925d1782..000000000 --- a/test/controllers/extranet/cohorts_controller_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test_helper" - -class Extranet::CohortsControllerTest < ActionDispatch::IntegrationTest - include ExtranetSetup - - def test_index - get education_cohorts_path - assert_response(:success) - end - - def test_show - get education_cohort_path(education_cohorts(:default_cohort)) - assert_response(:success) - end -end diff --git a/test/controllers/extranet/persons_controller_test.rb b/test/controllers/extranet/persons_controller_test.rb deleted file mode 100644 index 1b4d10523..000000000 --- a/test/controllers/extranet/persons_controller_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test_helper" - -class Extranet::PersonsControllerTest < ActionDispatch::IntegrationTest - include ExtranetSetup - - def test_index - get university_persons_path - assert_response(:success) - end - - def test_show - get university_person_path(university_people(:alumnus)) - assert_response(:success) - end -end -- GitLab