From 016a3db48fb8c3d1eca665810b8d8f37627b7534 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 18 Mar 2022 09:08:24 +0100 Subject: [PATCH] front --- .../extranet/persons_controller.rb | 12 +++++++++++ .../cohorts/_education_cohort.json.jbuilder | 2 -- .../education/cohorts/index.json.jbuilder | 1 - .../education/cohorts/show.json.jbuilder | 1 - app/views/extranet/cohorts/show.html.erb | 10 +++++++--- app/views/extranet/persons/index.html.erb | 20 +++++++++++++++++++ app/views/extranet/persons/show.html.erb | 3 +++ config/navigation.rb | 3 +++ 8 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 app/controllers/extranet/persons_controller.rb delete mode 100644 app/views/admin/education/cohorts/_education_cohort.json.jbuilder delete mode 100644 app/views/admin/education/cohorts/index.json.jbuilder delete mode 100644 app/views/admin/education/cohorts/show.json.jbuilder create mode 100644 app/views/extranet/persons/index.html.erb create mode 100644 app/views/extranet/persons/show.html.erb diff --git a/app/controllers/extranet/persons_controller.rb b/app/controllers/extranet/persons_controller.rb new file mode 100644 index 000000000..21739b53d --- /dev/null +++ b/app/controllers/extranet/persons_controller.rb @@ -0,0 +1,12 @@ +class Extranet::PersonsController < ApplicationController + load_and_authorize_resource class: University::Person::Alumnus, + through: :current_university, + through_association: :people + + def index + @people = @people.ordered.page(params[:page]) + end + + def show + end +end diff --git a/app/views/admin/education/cohorts/_education_cohort.json.jbuilder b/app/views/admin/education/cohorts/_education_cohort.json.jbuilder deleted file mode 100644 index ace1ee532..000000000 --- a/app/views/admin/education/cohorts/_education_cohort.json.jbuilder +++ /dev/null @@ -1,2 +0,0 @@ -json.extract! education_cohort, :id, :university_id, :program_id, :academic_year_id, :name, :created_at, :updated_at -json.url education_cohort_url(education_cohort, format: :json) diff --git a/app/views/admin/education/cohorts/index.json.jbuilder b/app/views/admin/education/cohorts/index.json.jbuilder deleted file mode 100644 index 757fffcec..000000000 --- a/app/views/admin/education/cohorts/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @education_cohorts, partial: "education_cohorts/education_cohort", as: :education_cohort diff --git a/app/views/admin/education/cohorts/show.json.jbuilder b/app/views/admin/education/cohorts/show.json.jbuilder deleted file mode 100644 index 8729cfa0b..000000000 --- a/app/views/admin/education/cohorts/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! "education_cohorts/education_cohort", education_cohort: @education_cohort diff --git a/app/views/extranet/cohorts/show.html.erb b/app/views/extranet/cohorts/show.html.erb index 80c570517..85133b974 100644 --- a/app/views/extranet/cohorts/show.html.erb +++ b/app/views/extranet/cohorts/show.html.erb @@ -2,6 +2,10 @@ <h1><%= @cohort %></h1> <p><%= @cohort.people.count %></p> -<% @cohort.people.each do |person| %> - <%= link_to person, person %> -<% end %> +<div class="row"> + <% @cohort.people.ordered.each do |person| %> + <div class="col-xxl-2 col-md-3"> + <%= link_to person, person %> + </div> + <% end %> +</div> diff --git a/app/views/extranet/persons/index.html.erb b/app/views/extranet/persons/index.html.erb new file mode 100644 index 000000000..aedc4001a --- /dev/null +++ b/app/views/extranet/persons/index.html.erb @@ -0,0 +1,20 @@ +<% 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' %> diff --git a/app/views/extranet/persons/show.html.erb b/app/views/extranet/persons/show.html.erb new file mode 100644 index 000000000..aa7949ff2 --- /dev/null +++ b/app/views/extranet/persons/show.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, @person %> + +<h1><%= @person %></h1> diff --git a/config/navigation.rb b/config/navigation.rb index 39f93342c..b79410e8c 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -16,5 +16,8 @@ SimpleNavigation::Configuration.run do |navigation| primary.item :cohorts, Education::Cohort.model_name.human(count: 2), education_cohorts_path + primary.item :person, + University::Person::Alumnus.model_name.human(count: 2), + university_persons_path end end -- GitLab