From 0abe9d61493154387fc422a3ab9c02b5a68adf40 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 18 Mar 2022 19:03:11 +0100 Subject: [PATCH] extranet --- .../stylesheets/application/layout.sass | 4 ++ .../extranet/persons_controller.rb | 1 - app/models/education/academic_year.rb | 4 ++ .../extranet/academic_years/index.html.erb | 8 ++-- .../extranet/academic_years/show.html.erb | 4 +- app/views/extranet/cohorts/show.html.erb | 10 +---- .../extranet/organizations/show.html.erb | 2 - app/views/extranet/persons/_list.html.erb | 39 +++++++++++++++++++ app/views/extranet/persons/index.html.erb | 19 +-------- app/views/extranet/persons/show.html.erb | 2 - app/views/layouts/application.html.erb | 1 + config/locales/education/en.yml | 6 +++ config/locales/education/fr.yml | 6 +++ config/navigation.rb | 3 -- 14 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 app/views/extranet/persons/_list.html.erb diff --git a/app/assets/stylesheets/application/layout.sass b/app/assets/stylesheets/application/layout.sass index 5e912ccbf..6616513cd 100644 --- a/app/assets/stylesheets/application/layout.sass +++ b/app/assets/stylesheets/application/layout.sass @@ -1,3 +1,7 @@ +.navbar-brand + img + max-height: 40px + footer margin-top: 100px diff --git a/app/controllers/extranet/persons_controller.rb b/app/controllers/extranet/persons_controller.rb index 21739b53d..24b55e34c 100644 --- a/app/controllers/extranet/persons_controller.rb +++ b/app/controllers/extranet/persons_controller.rb @@ -4,7 +4,6 @@ class Extranet::PersonsController < ApplicationController through_association: :people def index - @people = @people.ordered.page(params[:page]) end def show diff --git a/app/models/education/academic_year.rb b/app/models/education/academic_year.rb index fbacbef0f..ff203144a 100644 --- a/app/models/education/academic_year.rb +++ b/app/models/education/academic_year.rb @@ -21,6 +21,10 @@ class Education::AcademicYear < ApplicationRecord has_many :cohorts, class_name: 'Education::Cohort' + has_many :people, + class_name: 'University::Person', + through: :cohorts + scope :ordered, -> { order(year: :desc) } def to_s diff --git a/app/views/extranet/academic_years/index.html.erb b/app/views/extranet/academic_years/index.html.erb index e5c3cd212..b8e0b2fef 100644 --- a/app/views/extranet/academic_years/index.html.erb +++ b/app/views/extranet/academic_years/index.html.erb @@ -3,8 +3,9 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th>Year</th> - <th></th> + <th><%= Education::AcademicYear.model_name.human %></th> + <th><%= Education::Cohort.model_name.human(count: 2) %></th> + <th><%= University::Person::Alumnus.model_name.human(count: 2) %></th> </tr> </thead> @@ -12,7 +13,8 @@ <% @academic_years.each do |year| %> <tr> <td><%= link_to year, year %></td> - <td></td> + <td><%= year.cohorts.count %></td> + <td><%= year.people.count %></td> </tr> <% end %> </tbody> diff --git a/app/views/extranet/academic_years/show.html.erb b/app/views/extranet/academic_years/show.html.erb index 07d6cf7dd..63eacbade 100644 --- a/app/views/extranet/academic_years/show.html.erb +++ b/app/views/extranet/academic_years/show.html.erb @@ -1,7 +1,7 @@ <% content_for :title, @academic_year %> -<h1><%= @academic_year %></h1> - <% @academic_year.cohorts.each do |cohort| %> <%= link_to cohort, cohort %> <% end %> + +<%= render 'extranet/persons/list', people: @academic_year.people %> diff --git a/app/views/extranet/cohorts/show.html.erb b/app/views/extranet/cohorts/show.html.erb index 85133b974..153a03e9a 100644 --- a/app/views/extranet/cohorts/show.html.erb +++ b/app/views/extranet/cohorts/show.html.erb @@ -1,11 +1,3 @@ <% content_for :title, @cohort %> -<h1><%= @cohort %></h1> -<p><%= @cohort.people.count %></p> -<div class="row"> - <% @cohort.people.ordered.each do |person| %> - <div class="col-xxl-2 col-md-3"> - <%= link_to person, person %> - </div> - <% end %> -</div> +<%= render 'extranet/persons/list', people: @cohort.people %> diff --git a/app/views/extranet/organizations/show.html.erb b/app/views/extranet/organizations/show.html.erb index 39b24130f..1a8858a81 100644 --- a/app/views/extranet/organizations/show.html.erb +++ b/app/views/extranet/organizations/show.html.erb @@ -1,3 +1 @@ <% content_for :title, @organization %> - -<h1><%= @organization %></h1> diff --git a/app/views/extranet/persons/_list.html.erb b/app/views/extranet/persons/_list.html.erb new file mode 100644 index 000000000..8904fd0bf --- /dev/null +++ b/app/views/extranet/persons/_list.html.erb @@ -0,0 +1,39 @@ +<% +people_paged = people.ordered.page(params[:page]).per(60) +%> +<p><%= people.count %> <%= University::Person::Alumnus.model_name.human(count: 2).downcase %></p> + +<div class="row"> + <% people_paged.each do |person| %> + <div class="col-xxl-2 col-md-3"> + <article class="card mb-4"> + <div class="card-body"> + <%= link_to person, class: 'stretched-link' do %> + <span class="small"><%= person.first_name %></span><br> + <%= person.last_name %> + <% end %> + </div> + </article> + </div> + <% end %> +</div> + +<table class="<%= table_classes %>"> + <thead> + <tr> + <th>Name</th> + <th></th> + </tr> + </thead> + + <tbody> + <% people_paged.each do |person| %> + <tr> + <td><%= link_to person, person %></td> + <td></td> + </tr> + <% end %> + </tbody> +</table> + +<%= paginate people_paged, theme: 'bootstrap-5' %> diff --git a/app/views/extranet/persons/index.html.erb b/app/views/extranet/persons/index.html.erb index aedc4001a..dfd579b63 100644 --- a/app/views/extranet/persons/index.html.erb +++ b/app/views/extranet/persons/index.html.erb @@ -1,20 +1,3 @@ <% content_for :title, University::Person::Alumnus.model_name.human(count: 2) %> -<table class="<%= table_classes %>"> - <thead> - <tr> - <th>Name</th> - <th></th> - </tr> - </thead> - - <tbody> - <% @people.each do |person| %> - <tr> - <td><%= link_to person, person %></td> - <td></td> - </tr> - <% end %> - </tbody> -</table> -<%= paginate @people, theme: 'bootstrap-5' %> +<%= render 'extranet/persons/list', people: @people %> diff --git a/app/views/extranet/persons/show.html.erb b/app/views/extranet/persons/show.html.erb index aa7949ff2..c7de7737c 100644 --- a/app/views/extranet/persons/show.html.erb +++ b/app/views/extranet/persons/show.html.erb @@ -1,3 +1 @@ <% content_for :title, @person %> - -<h1><%= @person %></h1> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d650055e7..2fb378501 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,6 +13,7 @@ <body class="<%= body_classes %>"> <%= render 'nav' %> <main class="container"> + <h1><%= yield :title %></h1> <%= render_breadcrumbs builder: Appstack::BreadcrumbsOnRailsBuilder %> <%= yield %> </main> diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index d7d7ba80b..02c60018f 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -4,6 +4,12 @@ en: education: Education activerecord: models: + education/academic_year: + one: Year + other: Years + education/cohort: + one: Cohort + other: Cohorts education/program: one: Program other: Programs diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index 0082a690c..f7ff0e862 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -4,6 +4,12 @@ fr: education: Enseignement activerecord: models: + education/academic_year: + one: Année + other: Années + education/cohort: + one: Promotion + other: Promotions education/program: one: Formation other: Formations diff --git a/config/navigation.rb b/config/navigation.rb index b79410e8c..0cf5b2b4e 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -4,9 +4,6 @@ SimpleNavigation::Configuration.run do |navigation| navigation.highlight_on_subpath = true navigation.selected_class = 'active' navigation.items do |primary| - primary.item :home, - t('extranet.home'), - root_path primary.item :years, Education::AcademicYear.model_name.human(count: 2), education_academic_years_path -- GitLab