diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ddb1f9b14892952864005cc7807c0495be6273cc..9c856b761d7091cca3cde116bca33238a34f4a60 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,6 +1,7 @@ class Admin::UsersController < Admin::ApplicationController load_and_authorize_resource through: :current_university + has_scope :for_language has_scope :for_role has_scope :for_search_term diff --git a/app/models/university/person/experience.rb b/app/models/university/person/experience.rb index 7a07ecd396a65efa71e56702971532a3a3227802..3cee8c3347cd85fbc792cc0aac2bfa61b3ac4523 100644 --- a/app/models/university/person/experience.rb +++ b/app/models/university/person/experience.rb @@ -29,7 +29,5 @@ class University::Person::Experience < ApplicationRecord belongs_to :person belongs_to :organization, class_name: "University::Organization" - validates :from_year, presence: true - scope :ordered, -> { order(from_year: :desc)} end diff --git a/app/models/university/person/with_experiences.rb b/app/models/university/person/with_experiences.rb index 3de7c0e972a23cacb411d15a733cea149e1e5a2d..45b6cbba52826bf63258092a56f5e6039e9ba5c4 100644 --- a/app/models/university/person/with_experiences.rb +++ b/app/models/university/person/with_experiences.rb @@ -10,8 +10,7 @@ module University::Person::WithExperiences reject_if: :all_blank, allow_destroy: true - # PA FIXME - # validates_associated :experiences + validates_associated :experiences scope :for_alumni_organization, -> (organization_id) { left_joins(:experiences) diff --git a/app/models/user.rb b/app/models/user.rb index 0b7266b7eee47105b9edd65fa93bd81db33a373d..ee8e99f437f8767ad2cf4ffe352c06d4d73742e4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -65,6 +65,7 @@ class User < ApplicationRecord belongs_to :language scope :ordered, -> { order(:last_name, :first_name) } + scope :for_language, -> (language_id) { where(language_id: language_id) } scope :for_search_term, -> (term) { where(" unaccent(concat(users.first_name, ' ', users.last_name)) ILIKE unaccent(:term) OR diff --git a/app/services/filters/admin/users.rb b/app/services/filters/admin/users.rb index 5438038118677358d22fd77657476ee056b5660c..62691ceffc6174f0550cce0442cdbe03df72a762 100644 --- a/app/services/filters/admin/users.rb +++ b/app/services/filters/admin/users.rb @@ -3,6 +3,12 @@ module Filters def initialize(user) super add_search + add :for_language, + ::Language.all.map { |l| { to_s: I18n.t("languages.#{l.iso_code}"), id: l.id } }, + I18n.t( + 'filters.attributes.element', + element: Language.model_name.human.downcase + ) add :for_role, ::User.roles.keys.map { |r| { to_s: I18n.t("activerecord.attributes.user.roles.#{r}"), id: r } }, I18n.t('filters.attributes.role') diff --git a/app/views/admin/education/teachers/_list.html.erb b/app/views/admin/education/teachers/_list.html.erb index d9deb9b99ae6a7c2f3ce31b2884d0c70f2f11d80..cdcbf4649fcda328e908c0d62cc1d5e96c7c04a0 100644 --- a/app/views/admin/education/teachers/_list.html.erb +++ b/app/views/admin/education/teachers/_list.html.erb @@ -3,6 +3,8 @@ <tr> <th><%= University::Person.human_attribute_name('last_name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> + <th><%= Education::Program.model_name.human(count: 2) %></th> + <th></th> <th></th> </tr> </thead> @@ -11,9 +13,14 @@ <tr> <td><%= link_to teacher.last_name, admin_education_teacher_path(teacher) %></td> <td><%= link_to teacher.first_name, admin_education_teacher_path(teacher) %></td> + <td><%= teacher.involvements.size %></td> + <td class="p-0"> + <%= kamifusen_tag teacher.best_picture, + width: 40 if teacher.best_picture.attached? %> + </td> <td class="text-end"> <div class="btn-group" role="group"> - <%#= link_to t('edit'), + <%= link_to t('edit'), edit_admin_education_teacher_path(teacher), class: button_classes %> </div> diff --git a/app/views/admin/research/researchers/index.html.erb b/app/views/admin/research/researchers/index.html.erb index d0256588dcffd2d64877dc044571ab30f21803f9..d20f3591baaf0bbd51dbb3315f83e29b768694b8 100644 --- a/app/views/admin/research/researchers/index.html.erb +++ b/app/views/admin/research/researchers/index.html.erb @@ -7,6 +7,7 @@ <tr> <th><%= University::Person.human_attribute_name('name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> + <th></th> <th><%= t('research.number_of_articles') %></th> </tr> </thead> @@ -16,6 +17,10 @@ <tr> <td><%= link_to researcher.last_name, admin_research_researcher_path(researcher) %></td> <td><%= link_to researcher.first_name, admin_research_researcher_path(researcher) %></td> + <td class="p-0"> + <%= kamifusen_tag researcher.best_picture, + width: 40 if researcher.best_picture.attached? %> + </td> <td><%= researcher.research_journal_articles.count %></td> </tr> <% end %> diff --git a/app/views/admin/university/alumni/_list.html.erb b/app/views/admin/university/alumni/_list.html.erb index e8676343406419cacc52936259be44191a1fc8ca..212f867b40057810d3ddb5b1ac898737945cfed2 100644 --- a/app/views/admin/university/alumni/_list.html.erb +++ b/app/views/admin/university/alumni/_list.html.erb @@ -3,14 +3,23 @@ <tr> <th><%= University::Person.human_attribute_name('last_name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> + <th><%= Education::Cohort.model_name.human(count: 2) %></th> + <th><%= University::Person::Experience.model_name.human(count: 2) %></th> + <th></th> </tr> </thead> <tbody> <% alumni.each do |alumnus| %> <% path = admin_university_alumnus_path(alumnus) %> <tr> - <td><%= link_to alumnus.last_name, path %></td> - <td><%= link_to alumnus.first_name, path %></td> + <td><%= link_to_if can?(:read, alumnus), alumnus.last_name, path %></td> + <td><%= link_to_if can?(:read, alumnus), alumnus.first_name, path %></td> + <td><%= link_to_if can?(:update, alumnus), alumnus.cohorts.size, cohorts_admin_university_alumnus_path(alumnus) %></td> + <td><%= link_to_if can?(:update, alumnus), alumnus.experiences.size, experiences_admin_university_alumnus_path(alumnus) %></td> + <td class="p-0"> + <%= kamifusen_tag alumnus.best_picture, + width: 40 if alumnus.best_picture.attached? %> + </td> </tr> <% end %> </tbody> diff --git a/app/views/admin/university/alumni/show.html.erb b/app/views/admin/university/alumni/show.html.erb index 22ceb9fe5559597262e38e89aeebed86d23083da..fe27cf2c690364bbfd76336dbfa182ef58672feb 100644 --- a/app/views/admin/university/alumni/show.html.erb +++ b/app/views/admin/university/alumni/show.html.erb @@ -28,7 +28,7 @@ <% organization = experience.organization %> <li> <%= link_to_if can?(:read, organization), organization, [:admin, organization] %> - <%= "(#{experience.from_year} - #{experience.to_year.present? ? experience.to_year : t('today')})" %> + <%= "(#{experience.from_year} - #{experience.to_year.present? ? experience.to_year : t('today')})" if experience.from_year %> </li> <% end %> </ul> diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index bda69d5ff4c56faa033a05a8206a563a5a2a6b12..ba72682ee1b08d693970200749dfa7c7ffbe16b1 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -11,26 +11,20 @@ <th><%= User.human_attribute_name('first_name') %></th> <th><%= User.human_attribute_name('email') %></th> <th><%= User.human_attribute_name('role') %></th> - <th><%= User.human_attribute_name('language') %></th> <th></th> </tr> </thead> <tbody> <% @users.each do |user| %> <tr> - <td><%= user.last_name %></td> - <td><%= user.first_name %></td> + <td><%= link_to_if can?(:read, user), user.last_name, [:admin, user] %></td> + <td><%= link_to_if can?(:read, user), user.first_name, [:admin, user] %></td> <td><%= link_to user.email, [:admin, user] %></td> <td> <span class="badge bg-secondary"> <%= t("activerecord.attributes.user.roles.#{user.role}") %> </span> </td> - <td> - <span class="badge bg-secondary"> - <%= user.language %> - </span> - </td> <td class="text-end"> <div class="btn-group" role="group"> <%= edit_link user %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f21375bcb1c8d3dae92c76a7fbcb69317ac04bd8..87184496fcdebdd063422a2e420cdb847e208adb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -135,10 +135,10 @@ en: remove: Remove image filters: attributes: - date: Filter by Date + date: Filter by date element: Filter by %{element} - kind: Filter by Kind - role: Filter by Role + kind: Filter by kind + role: Filter by role buttons: expand: Filter table submit: Filter diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 54a1fbd9e2865aab7629c44f657134d1b0675e46..81430035d31a21e3da34a1b678bcd7f426b0c699 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -135,10 +135,10 @@ fr: remove: Supprimer l'image filters: attributes: - date: Filtrer par Date + date: Filtrer par date element: Filtrer par %{element} - kind: Filtrer par Type - role: Filtrer par Rôle + kind: Filtrer par type + role: Filtrer par rôle buttons: expand: Filtrer le tableau submit: Filtrer diff --git a/db/schema.rb b/db/schema.rb index 2b98e8d52f46d5b3a3882cf3ba22c24d00a3c7bb..45ca2a5032878221c9861fbfaf7fbb8b57ad814a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -502,23 +502,6 @@ ActiveRecord::Schema.define(version: 2022_05_30_094714) do t.index ["university_id"], name: "index_education_schools_on_university_id" end - create_table "external_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "title" - t.text "description" - t.string "address" - t.string "zipcode" - t.string "city" - t.string "country" - t.string "website" - t.string "phone" - t.string "mail" - t.boolean "active" - t.string "sirene" - t.integer "kind" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - end - create_table "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.integer "number_of_lines" t.jsonb "processing_errors" @@ -713,8 +696,8 @@ ActiveRecord::Schema.define(version: 2022_05_30_094714) do t.string "linkedin" t.boolean "is_alumnus", default: false t.text "description_short" - t.string "name" t.boolean "is_author" + t.string "name" t.integer "gender" t.date "birthdate" t.string "phone_professional"