diff --git a/app/controllers/admin/university/alumni/cohorts_controller.rb b/app/controllers/admin/university/alumni/cohorts_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..d58acefb4210abacd92a58af93a6bc89b1824f6c --- /dev/null +++ b/app/controllers/admin/university/alumni/cohorts_controller.rb @@ -0,0 +1,36 @@ +class Admin::University::Alumni::CohortsController < Admin::University::ApplicationController + load_and_authorize_resource :alumnus, + class: University::Person, + through: :current_university, + through_association: :people, + parent: false + def edit + breadcrumb + end + + def update + if @alumnus.update(cohorts_params) + redirect_to admin_university_alumnus_path(@alumnus), + notice: t('admin.successfully_updated_html', model: @alumnus.to_s) + else + render :edit + breadcrumb + end + end + + private + + def breadcrumb + super + add_breadcrumb University::Person::Alumnus.model_name.human(count: 2), + admin_university_alumni_path + add_breadcrumb @alumnus, admin_university_alumnus_path(@alumnus) + add_breadcrumb Education::Cohort.model_name.human(count: 2) + end + + def cohorts_params + params.require(:university_person) + .permit(cohorts_attributes: [:id, :program_id, :university_id, :year, :_destroy]) + end + +end diff --git a/app/controllers/admin/university/alumni/experiences_controller.rb b/app/controllers/admin/university/alumni/experiences_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..29d1689b065c7adb8969290d8c74f4687f62ef78 --- /dev/null +++ b/app/controllers/admin/university/alumni/experiences_controller.rb @@ -0,0 +1,36 @@ +class Admin::University::Alumni::ExperiencesController < Admin::University::ApplicationController + load_and_authorize_resource :alumnus, + class: University::Person, + through: :current_university, + through_association: :people, + parent: false + def edit + breadcrumb + end + + def update + if @alumnus.update(experiences_params) + redirect_to admin_university_alumnus_path(@alumnus), + notice: t('admin.successfully_updated_html', model: @alumnus.to_s) + else + render :edit + breadcrumb + end + end + + private + + def breadcrumb + super + add_breadcrumb University::Person::Alumnus.model_name.human(count: 2), + admin_university_alumni_path + add_breadcrumb @alumnus, admin_university_alumnus_path(@alumnus) + add_breadcrumb University::Person::Experience.model_name.human(count: 2) + end + + def experiences_params + params.require(:university_person) + .permit(experiences_attributes: [:id, :organization_id, :university_id, :from_year, :to_year, :_destroy]) + end + +end diff --git a/app/controllers/admin/university/alumni_controller.rb b/app/controllers/admin/university/alumni_controller.rb index ae1f4a38b11069de87c3ec4130ef6deb57147fd9..c267f090afd414dc189d33fecfb7cbf0712e0674 100644 --- a/app/controllers/admin/university/alumni_controller.rb +++ b/app/controllers/admin/university/alumni_controller.rb @@ -4,6 +4,7 @@ class Admin::University::AlumniController < Admin::University::ApplicationContro through_association: :people has_scope :for_search_term + has_scope :for_alumni_organization has_scope :for_alumni_program has_scope :for_alumni_year @@ -20,22 +21,6 @@ class Admin::University::AlumniController < Admin::University::ApplicationContro breadcrumb end - def edit_cohorts - breadcrumb - add_breadcrumb t('edit') - end - - def update_cohorts - if @alumnus.update(alumnus_params) - redirect_to admin_university_alumnus_path(@alumnus), - notice: t('admin.successfully_updated_html', model: @alumnus.to_s) - else - render :edit_cohorts - breadcrumb - add_breadcrumb t('edit') - end - end - protected def breadcrumb @@ -45,8 +30,4 @@ class Admin::University::AlumniController < Admin::University::ApplicationContro add_breadcrumb @alumnus, admin_university_alumni_path(@alumnus) if @alumnus end - def alumnus_params - params.require(:university_person) - .permit(cohorts_attributes: [:id, :program_id, :university_id, :year, :_destroy]) - end end diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 4ecd3416cb65e5531acd9fa4fc63320da5254f19..aba81c4f1626d1d99319f2c912b86f36109c2bf3 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -115,30 +115,6 @@ module Admin::ApplicationHelper } end - def icon_for(identifier) - icons = { - 'communication.website.menu.item.kind.administrators' => 'fas fa-user', - 'communication.website.menu.item.kind.authors' => 'fas fa-user', - 'communication.website.menu.item.kind.blank' => 'fas fa-font', - 'communication.website.menu.item.kind.news' => 'fas fa-newspaper', - 'communication.website.menu.item.kind.news_article' => 'fas fa-newspaper', - 'communication.website.menu.item.kind.news_category' => 'fas fa-newspaper', - 'communication.website.menu.item.kind.page' => 'fas fa-file', - 'communication.website.menu.item.kind.program' => 'fas fa-graduation-cap', - 'communication.website.menu.item.kind.programs' => 'fas fa-graduation-cap', - 'communication.website.menu.item.kind.research_article' => 'fas fa-flask', - 'communication.website.menu.item.kind.research_articles' => 'fas fa-flask', - 'communication.website.menu.item.kind.research_volumes' => 'fas fa-flask', - 'communication.website.menu.item.kind.research_volume' => 'fas fa-flask', - 'communication.website.menu.item.kind.researchers' => 'fas fa-user', - 'communication.website.menu.item.kind.organizations' => 'fas fa-building', - 'communication.website.menu.item.kind.staff' => 'fas fa-user', - 'communication.website.menu.item.kind.teachers' => 'fas fa-user', - 'communication.website.menu.item.kind.url' => 'fas fa-globe', - } - icons[identifier] if icons.has_key? identifier - end - private def polymorphic_url_param(object_or_class, **options) diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index 5c0cebf91d28576e6837d746a9d55fd93344e758..9a26ebcec55adaf93fe35d5911fe6e1e4d4d1e1b 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -55,6 +55,7 @@ class Communication::Website::Menu::Item < ApplicationRecord page: 20, programs: 30, program: 31, + diplomas: 32, news: 40, news_category: 41, news_article: 42, @@ -75,6 +76,31 @@ class Communication::Website::Menu::Item < ApplicationRecord after_commit :sync_menu + def self.icon_for(kind) + icons = { + 'administrators' => 'fas fa-user', + 'authors' => 'fas fa-user', + 'blank' => 'fas fa-font', + 'diplomas' => 'fas fa-award', + 'news' => 'fas fa-newspaper', + 'news_article' => 'fas fa-newspaper', + 'news_category' => 'fas fa-newspaper', + 'page' => 'fas fa-file', + 'program' => 'fas fa-graduation-cap', + 'programs' => 'fas fa-graduation-cap', + 'research_article' => 'fas fa-flask', + 'research_articles' => 'fas fa-flask', + 'research_volumes' => 'fas fa-flask', + 'research_volume' => 'fas fa-flask', + 'researchers' => 'fas fa-user', + 'organizations' => 'fas fa-building', + 'staff' => 'fas fa-user', + 'teachers' => 'fas fa-user', + 'url' => 'fas fa-globe', + } + icons[kind] if icons.has_key? kind + end + def to_s "#{title}" end diff --git a/app/models/communication/website/menu/item/with_targets.rb b/app/models/communication/website/menu/item/with_targets.rb index 0dab54e1304fd086d1cce889201d5c36e1ed0171..815a3887f8241c40801634244ac95d3a4b3fd541 100644 --- a/app/models/communication/website/menu/item/with_targets.rb +++ b/app/models/communication/website/menu/item/with_targets.rb @@ -23,6 +23,10 @@ module Communication::Website::Menu::Item::WithTargets Static.clean_path "#{website.special_page(:education_programs).path}#{about.path}" end + def target_for_diplomas + Static.clean_path website.special_page(:education_diplomas).path + end + def target_for_news Static.clean_path website.special_page(:communication_posts).path end diff --git a/app/models/communication/website/page/with_kind.rb b/app/models/communication/website/page/with_kind.rb index 640d60e836e42258f44e7954a7305978ca99daaf..22644ce295943ec6ef4268a7ac75c6e47ad6d624 100644 --- a/app/models/communication/website/page/with_kind.rb +++ b/app/models/communication/website/page/with_kind.rb @@ -7,6 +7,7 @@ module Communication::Website::Page::WithKind home: 0, communication_posts: 10, education_programs: 20, + education_diplomas: 21, research_articles: 30, research_volumes: 32, legal_terms: 80, @@ -23,6 +24,7 @@ module Communication::Website::Page::WithKind SPECIAL_PAGES_WITH_GIT_SPECIAL_PATH = [ 'communication_posts', 'education_programs', + 'education_diplomas', 'research_articles', 'research_volumes', 'organizations', diff --git a/app/models/communication/website/with_dependencies.rb b/app/models/communication/website/with_dependencies.rb index fdeabafae6635f44792aa6af8bc5926fe61cc409..7abcbf7b76b77acf01702e28231d1164948b378e 100644 --- a/app/models/communication/website/with_dependencies.rb +++ b/app/models/communication/website/with_dependencies.rb @@ -158,6 +158,10 @@ module Communication::Website::WithDependencies about && about.has_education_programs? end + def has_education_diplomas? + about && about.has_education_diplomas? + end + def has_research_articles? about && about.has_research_articles? end diff --git a/app/models/communication/website/with_menu_items.rb b/app/models/communication/website/with_menu_items.rb index 3221927e0af25cf732b530ccf8edc6b3c347083c..3872452026f4c589a13f2d1fab6a2ba0d04cf257 100644 --- a/app/models/communication/website/with_menu_items.rb +++ b/app/models/communication/website/with_menu_items.rb @@ -28,6 +28,10 @@ module Communication::Website::WithMenuItems has_education_programs? end + def menu_item_kind_diplomas? + has_education_diplomas? + end + def menu_item_kind_news? has_communication_posts? end diff --git a/app/models/communication/website/with_special_pages.rb b/app/models/communication/website/with_special_pages.rb index 4b01e1a9dceef3b4b743ab306330a559615abd4c..56d01100c365961cf40de6c4fd6bdeb300bcde0b 100644 --- a/app/models/communication/website/with_special_pages.rb +++ b/app/models/communication/website/with_special_pages.rb @@ -13,7 +13,7 @@ module Communication::Website::WithSpecialPages def create_missing_special_pages homepage = create_special_page('home') # first level pages with test - ['legal_terms', 'sitemap', 'privacy_policy', 'communication_posts', 'education_programs', 'research_articles', 'research_volumes', 'organizations'].each do |kind| + ['legal_terms', 'sitemap', 'privacy_policy', 'communication_posts', 'education_programs', 'education_diplomas', 'research_articles', 'research_volumes', 'organizations'].each do |kind| create_special_page(kind, homepage.id) if public_send("has_#{kind}?") end # team pages @@ -38,7 +38,7 @@ module Communication::Website::WithSpecialPages def create_special_page(kind, parent_id = nil) i18n_key = "communication.website.pages.defaults.#{kind}" - page = pages.where(kind: kind).first_or_create( + page = pages.where(kind: kind).first_or_initialize( title: I18n.t("#{i18n_key}.title"), slug: I18n.t("#{i18n_key}.slug"), description_short: I18n.t("#{i18n_key}.description_short"), @@ -46,6 +46,9 @@ module Communication::Website::WithSpecialPages published: true, university_id: university_id ) + if page.new_record? + page.save_and_sync + end page end diff --git a/app/models/concerns/aboutable.rb b/app/models/concerns/aboutable.rb index c8347a0809fbaa372f4623b09d1d1f7963e8095d..05e71acfb1eddb0fa29e25a702515b8123c5bdba 100644 --- a/app/models/concerns/aboutable.rb +++ b/app/models/concerns/aboutable.rb @@ -17,6 +17,10 @@ module Aboutable raise NotImplementedError end + def has_education_diplomas? + raise NotImplementedError + end + def has_research_articles? raise NotImplementedError end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 48d81765c55fa7a6318005ee2a47055701d54f6f..e4cce47c368ce347f0ed30764a28df5ef26e9f57 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -184,6 +184,10 @@ class Education::Program < ApplicationRecord published? || descendants.any?(&:published?) end + def has_education_diplomas? + diploma.present? || descendants.any? { |descendant| descendant.diploma.present? } + end + def has_research_articles? false end diff --git a/app/models/education/school.rb b/app/models/education/school.rb index a44a083c57a92dc93765c65fd864de704f11d2bf..aadc491bb702cde9a656eab235a75bb4b55212d1 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -65,17 +65,18 @@ class Education::School < ApplicationRecord def git_dependencies(website) dependencies = [self] - dependencies += published_programs - + published_programs.map(&:active_storage_blobs).flatten if has_education_programs? - dependencies += teachers - + teachers.map(&:teacher) - + teachers.map(&:active_storage_blobs).flatten if has_teachers? - dependencies += researchers - + researchers.map(&:researcher) - + researchers.map(&:active_storage_blobs).flatten if has_researchers? - dependencies += administrators - + administrators.map(&:administrator) - + administrators.map(&:active_storage_blobs).flatten if has_administrators? + dependencies += published_programs + + published_programs.map(&:active_storage_blobs).flatten if has_education_programs? + dependencies += diplomas if has_education_diplomas? + dependencies += teachers + + teachers.map(&:teacher) + + teachers.map(&:active_storage_blobs).flatten if has_teachers? + dependencies += researchers + + researchers.map(&:researcher) + + researchers.map(&:active_storage_blobs).flatten if has_researchers? + dependencies += administrators + + administrators.map(&:administrator) + + administrators.map(&:active_storage_blobs).flatten if has_administrators? dependencies end diff --git a/app/models/education/school/with_programs.rb b/app/models/education/school/with_programs.rb index 836aab7fec8dc65ee44c1e3245710766400504e4..a33f3028b0b8b12f0561be368de818846df0c4fe 100644 --- a/app/models/education/school/with_programs.rb +++ b/app/models/education/school/with_programs.rb @@ -16,9 +16,17 @@ module Education::School::WithPrograms foreign_key: 'education_school_id', association_foreign_key: 'education_program_id' + has_many :diplomas, + through: :programs, + source: :diploma + end def has_education_programs? published_programs.any? end + + def has_education_diplomas? + diplomas.any? + end end diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb index 2ed9428145269dc38d87a5fc43d61e8ce9a5c706..885d92465a6b402e3b55488b8f25a9076550939c 100644 --- a/app/models/research/journal.rb +++ b/app/models/research/journal.rb @@ -39,7 +39,7 @@ class Research::Journal < ApplicationRecord unaccent(research_journals.description) ILIKE unaccent(:term) OR unaccent(research_journals.issn) ILIKE unaccent(:term) OR unaccent(research_journals.repository) ILIKE unaccent(:term) OR - unaccent(research_journals.title) ILIKE unaccent(:term) + unaccent(research_journals.title) ILIKE unaccent(:term) ", term: "%#{sanitize_sql_like(term)}%") } @@ -86,6 +86,10 @@ class Research::Journal < ApplicationRecord false end + def has_education_diplomas? + false + end + def has_research_articles? published_articles.published.any? end diff --git a/app/models/research/laboratory.rb b/app/models/research/laboratory.rb index 2908de92a196b43de0245cceb3cbdbf432572651..964f4dbd9bfb3db828d3a3719e63e4e6b20a49a4 100644 --- a/app/models/research/laboratory.rb +++ b/app/models/research/laboratory.rb @@ -43,7 +43,7 @@ class Research::Laboratory < ApplicationRecord unaccent(research_laboratories.city) ILIKE unaccent(:term) OR unaccent(research_laboratories.country) ILIKE unaccent(:term) OR unaccent(research_laboratories.name) ILIKE unaccent(:term) OR - unaccent(research_laboratories.zipcode) ILIKE unaccent(:term) + unaccent(research_laboratories.zipcode) ILIKE unaccent(:term) ", term: "%#{sanitize_sql_like(term)}%") } @@ -76,6 +76,10 @@ class Research::Laboratory < ApplicationRecord false end + def has_education_diplomas? + false + end + def has_research_articles? false end diff --git a/app/models/university/person.rb b/app/models/university/person.rb index ae8ee83c2424ef43a6aa8c436c82234a5a56cc68..85e28db5f4278130e42c639b9323d1577ca9f254 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -42,10 +42,11 @@ class University::Person < ApplicationRecord include WithUniversity include WithGit include WithBlobs + include WithEducation + include WithExperiences include WithSlug include WithPicture include WithRoles - include WithEducation LIST_OF_ROLES = [ :administration, diff --git a/app/models/university/person/experience.rb b/app/models/university/person/experience.rb index 3cee8c3347cd85fbc792cc0aac2bfa61b3ac4523..7a07ecd396a65efa71e56702971532a3a3227802 100644 --- a/app/models/university/person/experience.rb +++ b/app/models/university/person/experience.rb @@ -29,5 +29,7 @@ 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_education.rb b/app/models/university/person/with_education.rb index f22aed32deca953f0c34397016482345a9a9f67b..15a7e3682261b48ebe8882a95c1fee4b95f6f43f 100644 --- a/app/models/university/person/with_education.rb +++ b/app/models/university/person/with_education.rb @@ -2,46 +2,45 @@ module University::Person::WithEducation extend ActiveSupport::Concern included do - has_many :involvements_as_teacher, - -> { where(kind: 'teacher') }, - class_name: 'University::Person::Involvement', - dependent: :destroy + has_many :involvements_as_teacher, + -> { where(kind: 'teacher') }, + class_name: 'University::Person::Involvement', + dependent: :destroy - has_many :education_programs_as_teacher, - through: :involvements_as_teacher, - source: :target, - source_type: "Education::Program" + has_many :education_programs_as_teacher, + through: :involvements_as_teacher, + source: :target, + source_type: "Education::Program" - has_many :education_programs_as_administrator, - -> { distinct }, - through: :roles_as_administrator, - source: :target, - source_type: "Education::Program" + has_many :education_programs_as_administrator, + -> { distinct }, + through: :roles_as_administrator, + source: :target, + source_type: "Education::Program" - has_many :experiences, class_name: "University::Person::Experience" - - has_and_belongs_to_many :cohorts, - class_name: '::Education::Cohort', - foreign_key: 'university_person_id', - association_foreign_key: 'education_cohort_id' + has_and_belongs_to_many :cohorts, + class_name: '::Education::Cohort', + foreign_key: 'university_person_id', + association_foreign_key: 'education_cohort_id' accepts_nested_attributes_for :cohorts, reject_if: :all_blank, allow_destroy: true + # Dénormalisation des liens via cohorts, pour la recherche par facettes + has_and_belongs_to_many :diploma_years, + class_name: 'Education::AcademicYear', + foreign_key: 'university_person_id', + association_foreign_key: 'education_academic_year_id' + + has_and_belongs_to_many :diploma_programs, + class_name: 'Education::Program', + foreign_key: 'university_person_id', + association_foreign_key: 'education_program_id' + before_validation :find_cohorts validates_associated :cohorts - # Dénormalisation des liens via cohorts, pour la recherche par facettes - has_and_belongs_to_many :diploma_years, - class_name: 'Education::AcademicYear', - foreign_key: 'university_person_id', - association_foreign_key: 'education_academic_year_id' - has_and_belongs_to_many :diploma_programs, - class_name: 'Education::Program', - foreign_key: 'university_person_id', - association_foreign_key: 'education_program_id' - scope :for_alumni_program, -> (program_id) { left_joins(:cohorts) .where(education_cohorts: { program_id: program_id }) diff --git a/app/models/university/person/with_experiences.rb b/app/models/university/person/with_experiences.rb new file mode 100644 index 0000000000000000000000000000000000000000..99c15cc16968a80397088529a64171cbbc1f2144 --- /dev/null +++ b/app/models/university/person/with_experiences.rb @@ -0,0 +1,24 @@ +module University::Person::WithExperiences + extend ActiveSupport::Concern + + included do + + has_many :experiences, + class_name: "University::Person::Experience" + + accepts_nested_attributes_for :experiences, + reject_if: :all_blank, + allow_destroy: true + + validates_associated :experiences + + scope :for_alumni_organization, -> (organization_id) { + left_joins(:experiences) + .where(university_person_experiences: { organization_id: organization_id }) + .select("university_people.*") + .distinct + } + + end + +end diff --git a/app/services/filters/admin/university/alumni.rb b/app/services/filters/admin/university/alumni.rb index ad0f53c253ed0112cf31160e47c89b0a43518019..fec367846af24ff838282d58eb38449375bee766 100644 --- a/app/services/filters/admin/university/alumni.rb +++ b/app/services/filters/admin/university/alumni.rb @@ -2,7 +2,12 @@ module Filters class Admin::University::Alumni < Filters::Base def initialize(user) super - add_search + add :for_alumni_organization, + user.university.organizations.ordered, + I18n.t( + 'filters.attributes.element', + element: University::Organization.model_name.human.downcase + ) add :for_alumni_program, user.university.education_programs, I18n.t( @@ -17,6 +22,7 @@ module Filters 'filters.attributes.element', element: Education::AcademicYear.model_name.human.downcase ) + add_search end end end diff --git a/app/views/admin/communication/websites/configs/permalinks/static.html.erb b/app/views/admin/communication/websites/configs/permalinks/static.html.erb index 87e03483a79d40ae9eb7b773232de10ccbc1edcb..1d0f127129dfcb73842d6cbe436abe56125b5cb7 100644 --- a/app/views/admin/communication/websites/configs/permalinks/static.html.erb +++ b/app/views/admin/communication/websites/configs/permalinks/static.html.erb @@ -13,6 +13,9 @@ organizations: <%= @website.special_page(:organizations).path_without_language <% if @website.has_authors? %> authors: <%= @website.special_page(:persons).path_without_language %>:slug/<%= @website.special_page(:communication_posts).slug %>/ <% end %> +<% if @website.has_education_diplomas? %> +diplomas: <%= @website.special_page(:education_diplomas).path_without_language %>:slug/ +<% end %> <%# ces paths complémentaires sont nécessaires à Hugo mais on ne les utilise pas %> <% if @website.has_administrators? %> administrators: <%= @website.special_page(:persons).path_without_language %>:slug/roles/ diff --git a/app/views/admin/communication/websites/menus/items/_form.html.erb b/app/views/admin/communication/websites/menus/items/_form.html.erb index d83ae39ddb41548bf40e361d20d6ab0383449cdc..847bb6dbd3e5bad709721fc2d38afbd339fe560a 100644 --- a/app/views/admin/communication/websites/menus/items/_form.html.erb +++ b/app/views/admin/communication/websites/menus/items/_form.html.erb @@ -64,7 +64,7 @@ <div class="card kind" data-kind="<%= kind %>"> <div class="card-body"> <p class="text-end mb-0"> - <i class="<%= icon_for "communication.website.menu.item.kind.#{kind}" %> fa-2x"></i><br> + <i class="<%= Communication::Website::Menu::Item.icon_for(kind) %> fa-2x"></i><br> </p> <p class="mb-0"> <%= t "enums.communication.website.menu.item.kind.#{kind}" %> diff --git a/app/views/admin/education/cohorts/show.html.erb b/app/views/admin/education/cohorts/show.html.erb index c043e0c1506f19df53ce96dde779d1bc24229171..9453d4e8edeedb495d7c5e4ec94dbf61e048bfe2 100644 --- a/app/views/admin/education/cohorts/show.html.erb +++ b/app/views/admin/education/cohorts/show.html.erb @@ -13,6 +13,7 @@ </div> </div> -<h2><%= University::Person::Alumnus.model_name.human(count: 2) %></h2> - -<%= render 'admin/university/alumni/list', alumni: @cohort.people.ordered %> +<% if @cohort.people.any? %> + <h2><%= University::Person::Alumnus.model_name.human(count: 2) %></h2> + <%= render 'admin/university/alumni/list', alumni: @cohort.people.ordered %> +<% end %> diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb index 071e23c36b7fd28468ecb770b50ce8487a707fd4..57d6284710e6a86f2a4d33d245ce894e29b58e92 100644 --- a/app/views/admin/education/diplomas/static.html.erb +++ b/app/views/admin/education/diplomas/static.html.erb @@ -1,6 +1,7 @@ --- title: > <%= prepare_text_for_static @about.name %> +slug: "<%= @about.slug %>" short_name: > <%= prepare_text_for_static @about.short_name %> level: <%= @about.level_i18n %> diff --git a/app/views/admin/university/alumni/_cohort_fields.html.erb b/app/views/admin/university/alumni/cohorts/_cohort_fields.html.erb similarity index 64% rename from app/views/admin/university/alumni/_cohort_fields.html.erb rename to app/views/admin/university/alumni/cohorts/_cohort_fields.html.erb index 632f02976117be7297d2e905c93f94dd629e4981..4887bdd6ba803495852a0b5f38c3259f58907e5d 100644 --- a/app/views/admin/university/alumni/_cohort_fields.html.erb +++ b/app/views/admin/university/alumni/cohorts/_cohort_fields.html.erb @@ -4,10 +4,10 @@ <div class="card-body"> <div class="row"> <div class="col-md-5"> - <%= f.input :university_id, - as: :hidden, - input_html: { value: current_university.id }, - wrapper: false %> + <%= f.input :university_id, + as: :hidden, + input_html: { value: current_university.id }, + wrapper: false %> <%= f.association :program, collection: collection_tree(current_university.education_programs), label_method: ->(p) { sanitize p[:label] }, @@ -18,13 +18,13 @@ wrapper: false %> </div> <div class="col-md-6"> - <%= f.input :year, - as: :select, - collection: ((Time.now.year + 5).downto(1950)), - label: false, - include_blank: t('simple_form.include_blanks.defaults.year'), - required: true, - wrapper: false %> + <%= f.input :year, + as: :select, + collection: ((Time.now.year + 5).downto(1950)), + label: false, + include_blank: t('simple_form.include_blanks.defaults.year'), + required: true, + wrapper: false %> </div> <div class="col-md-1 text-end"> <%= link_to_remove_association '<i class="fas fa-times"></i>'.html_safe, diff --git a/app/views/admin/university/alumni/edit_cohorts.html.erb b/app/views/admin/university/alumni/cohorts/edit.html.erb similarity index 76% rename from app/views/admin/university/alumni/edit_cohorts.html.erb rename to app/views/admin/university/alumni/cohorts/edit.html.erb index ea332608a5f07d98cbd8af1d4797073b4af5b2fb..c4f3de3af35601e502a52c330ea8a90eb710bb4b 100644 --- a/app/views/admin/university/alumni/edit_cohorts.html.erb +++ b/app/views/admin/university/alumni/cohorts/edit.html.erb @@ -1,8 +1,8 @@ <% content_for :title, @alumnus %> -<h2 class="h3"><%= Education::Program.model_name.human(count: 2) %></h2> +<h2 class="h3"><%= Education::Cohort.model_name.human(count: 2) %></h2> -<%= simple_form_for [:admin, @alumnus], url: edit_cohorts_admin_university_alumnus_path(@alumnus) do |f| %> +<%= simple_form_for [:admin, @alumnus], url: cohorts_admin_university_alumnus_path(@alumnus) do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> @@ -21,11 +21,12 @@ <div class="col-md-10"> <div id="cohorts"> <%= f.simple_fields_for :cohorts, @alumnus.cohorts.sort_by { |c| [c.year ? 0 : 1, c.year] }.reverse, include_id: false do |cohort_f| %> - <%= render 'admin/university/alumni/cohort_fields', f: cohort_f, include_id: true %> + <%= render 'admin/university/alumni/cohorts/cohort_fields', f: cohort_f, include_id: true %> <% end %> </div> </div> </div> + <% content_for :action_bar_right do %> <%= submit f %> <% end %> diff --git a/app/views/admin/university/alumni/experiences/_experience_fields.html.erb b/app/views/admin/university/alumni/experiences/_experience_fields.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..eb6b7bd848e67df626f8d5ad055eadcb801578fb --- /dev/null +++ b/app/views/admin/university/alumni/experiences/_experience_fields.html.erb @@ -0,0 +1,47 @@ +<% include_id ||= false %> +<div class="nested-fields"> + <div class="card mb-3"> + <div class="card-body"> + <div class="row"> + <div class="col-md-5"> + <%= f.input :university_id, + as: :hidden, + input_html: { value: current_university.id }, + wrapper: false %> + <%= f.association :organization, + collection: current_university.organizations.ordered, + label: false, + include_blank: t('simple_form.include_blanks.defaults.organization'), + hint: can?(:create, University::Organization) ? t('university.person.experience.no_organization_hint_html', url: new_admin_university_organization_path) : + t('university.person.experience.no_organization_hint_no_access_html'), + required: true, + wrapper: false %> + </div> + <div class="col-md-3"> + <%= f.input :from_year, + as: :select, + collection: ((Time.now.year).downto(1950)), + label: false, + include_blank: University::Person::Experience.human_attribute_name('from_year'), + required: true, + wrapper: false %> + </div> + <div class="col-md-3"> + <%= f.input :to_year, + as: :select, + collection: ((Time.now.year).downto(1950)), + label: false, + include_blank: University::Person::Experience.human_attribute_name('to_year'), + required: true, + wrapper: false %> + </div> + <div class="col-md-1 text-end"> + <%= link_to_remove_association '<i class="fas fa-times"></i>'.html_safe, + f, + class: 'btn btn-sm btn-danger' %> + </div> + </div> + </div> + <%= f.hidden_field :id if include_id %> + </div> +</div> diff --git a/app/views/admin/university/alumni/experiences/edit.html.erb b/app/views/admin/university/alumni/experiences/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e21fe1ce8a5bd9f3e8fca697cb9cc86f157f74a8 --- /dev/null +++ b/app/views/admin/university/alumni/experiences/edit.html.erb @@ -0,0 +1,33 @@ +<% content_for :title, @alumnus %> + +<h2 class="h3"><%= University::Person::Experience.model_name.human(count: 2) %></h2> + +<%= simple_form_for [:admin, @alumnus], url: experiences_admin_university_alumnus_path(@alumnus) do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + + <div class="row"> + + <div class="col-md-2"> + <%= link_to_add_association t('add'), f, :experiences, + class: button_classes, + data: { + 'association-insertion-method': 'append', + 'association-insertion-node': '#experiences', + } %> + + </div> + + <div class="col-md-10"> + <div id="experiences"> + <%= f.simple_fields_for :experiences, @alumnus.experiences.sort_by(&:from_year).reverse, include_id: false do |experience_f| %> + <%= render 'admin/university/alumni/experiences/experience_fields', f: experience_f, include_id: true %> + <% end %> + </div> + </div> + </div> + + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/university/alumni/show.html.erb b/app/views/admin/university/alumni/show.html.erb index c122295e9ef3ad42c37457d47f6a4a3f50faeb2c..22ceb9fe5559597262e38e89aeebed86d23083da 100644 --- a/app/views/admin/university/alumni/show.html.erb +++ b/app/views/admin/university/alumni/show.html.erb @@ -17,8 +17,28 @@ </div> <% end %> +<% if @alumnus.experiences.any? %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h2 class="card-title mb-0 h5"><%= University::Person::Experience.model_name.human(count: @alumnus.experiences.count) %></h2> + </div> + <div class="card-body"> + <ul class="list-unstyled"> + <% @alumnus.experiences.ordered.each do |experience| %> + <% 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')})" %> + </li> + <% end %> + </ul> + </div> + </div> +<% end %> + <% content_for :action_bar_right do %> <%= edit_link @alumnus %> - <%= link_to t('university.manage_cohorts'), edit_cohorts_admin_university_alumnus_path(@alumnus), class: button_classes if can?(:update, @alumnus) %> + <%= link_to t('university.manage_cohorts'), cohorts_admin_university_alumnus_path(@alumnus), class: button_classes if can?(:update, @alumnus) %> + <%= link_to t('university.manage_experiences'), experiences_admin_university_alumnus_path(@alumnus), class: button_classes if can?(:update, @alumnus) %> <% end %> diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index 4cc66d50f0999dcdb5c36316f72e614a8bc16189..c48ddd06db63692ca7d0b6b20d589ff64750bf58 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -113,6 +113,35 @@ </div> </div> +<% if @organization.experiences.any? %> + <h2><%= University::Person::Alumnus.model_name.human(count: 2) %></h2> + + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= University::Person.human_attribute_name('last_name') %></th> + <th><%= University::Person.human_attribute_name('first_name') %></th> + <th><%= t('university.person.experience.period') %></th> + </tr> + </thead> + <tbody> + <% @organization.experiences.ordered.each do |experience| %> + <% + alumnus = experience.person + path = admin_university_alumnus_path(alumnus) + %> + <tr> + <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> + <%= "#{experience.from_year} - #{experience.to_year.present? ? experience.to_year : t('today')}" %> + </td> + </tr> + <% end %> + </tbody> + </table> +<% end %> + <% content_for :action_bar_left do %> <%= destroy_link @organization %> <% end %> diff --git a/app/views/extranet/organizations/show.html.erb b/app/views/extranet/organizations/show.html.erb index c1a410e2185f5f6f1bdaa326da6d41d8ae635501..67d044f7d9422422cebad5a343c9b20bf882274f 100644 --- a/app/views/extranet/organizations/show.html.erb +++ b/app/views/extranet/organizations/show.html.erb @@ -42,7 +42,7 @@ <%= experience.description %><br> <% end %> <%= "#{experience.from_year} —" if experience.from_year %> - <%= experience.to_year || University::Person::Experience.human_attribute_name(:today) %> + <%= experience.to_year || t('today') %> </p> </div> </li> diff --git a/app/views/extranet/persons/show.html.erb b/app/views/extranet/persons/show.html.erb index d40ac0236c9b3f98038febdd721815879bc79e18..a6901c29439dc1f2593ff8018c86e9629a202f3c 100644 --- a/app/views/extranet/persons/show.html.erb +++ b/app/views/extranet/persons/show.html.erb @@ -30,7 +30,7 @@ <p><b><%= experience.description %></b></p> <p class="mb-0"> <%= "#{experience.from_year} —" if experience.from_year %> - <%= experience.to_year || University::Person::Experience.human_attribute_name(:today) %> + <%= experience.to_year || t('today') %> </p> </div> <div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 6fca96732b7f94d15297f83fc4a388d0186208d5..3cd1b9391ba5910011f9ca1e82fec5e361bf295d 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -302,6 +302,11 @@ en: description_short: List of posts slug: posts title: Posts + education_diplomas: + admin_description: list of available diplomas + description_short: List of available diplomas + slug: diplomas + title: Diplomas education_programs: admin_description: list of available programs description_short: List of available programs @@ -389,6 +394,7 @@ en: administrators: Administration staff authors: Editorial staff blank: Title + diplomas: Diplomas index news: News index news_article: Specific news news_category: News category diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 1b62eae7a6b24508a4308cf7ac59e77797b0b9ac..7c63c15256de5353dd236fa7fe12c5b032656772 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -184,7 +184,7 @@ fr: add_file: Ajouter un fichier file_label: Fichier title_label: Titre - title_placeholder: Entrer le titre du fichier + title_placeholder: Entrer le titre du fichier remove_file: Supprimer le fichier gallery: edit: @@ -305,6 +305,11 @@ fr: description_short: Liste des actualités slug: actualites title: Actualités + education_diplomas: + admin_description: liste des diplômes proposés + description_short: Liste des diplômes proposés + slug: diplomes + title: "Diplômes" education_programs: admin_description: liste des formations proposées description_short: Liste des formations proposées @@ -392,6 +397,7 @@ fr: administrators: Équipe administrative authors: Équipe éditoriale blank: Titre intermédiaire + diplomas: Liste des diplômes news: Liste des actualités news_article: Actualité spécifique news_category: Catégorie d'actualités diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index e83ec1619925852f0974c3692cc7f9570885530e..d3f7ef9cdf5b376e498c8bf1a0cc43ea2a364f43 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -142,3 +142,6 @@ en: evaluation: Means mobilised to measure with objective criteria the beneficiary's achievements during and/or at the end of the service. accessibility: Conditions of reception and access for people with disabilities (premises, adaptation of the means of provision). description: Plain text without HTML, dedicated to SEO + include_blanks: + defaults: + program: "Select a program" diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index 1c657a83016d3269dec0c90c9042cfff7aa43c70..41e74e7d34275b13977584e24349e52cd48a324b 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -160,3 +160,6 @@ fr: evaluation: Moyens mobilisés pour mesurer à l'aide de critères objectifs les acquis du bénéficiaire en cours et/ou à la fin de la prestation. accessibility: Conditions d'accueil et d’accès des publics en situation de handicap (locaux, adaptation des moyens de la prestation). description: Texte simple, sans HTML, pour le SEO + include_blanks: + defaults: + program: "Sélectionnez une formation" diff --git a/config/locales/en.yml b/config/locales/en.yml index bc9a6fa7cb07d0a75ab9e4adcf6ed0907b4d780d..f4364a70e0b28ffa7e4f297d8f4aa1c39160d998 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -49,7 +49,7 @@ en: status: Inherited value pending_tasks: label: Background tasks pending - hint: Those tasks precompute your data in order to minimize its carbon footprint. It creates a delay before your changes are online. + hint: Those tasks precompute your data in order to minimize its carbon footprint. It creates a delay before your changes are online. password_hint: Leave blank if you do not wish to change the password. successfully_created_html: "<i>%{model}</i> was successfully created." successfully_destroyed_html: "<i>%{model}</i> was successfully destroyed." @@ -172,7 +172,6 @@ en: defaults: language: "Select a language" person: "Select a person" - program: "Select a program" simple_form_password_with_hints: test_chars: "%{min_length} characters min." show: Show @@ -185,6 +184,7 @@ en: date_only: "%m/%d/%Y" date_with_explicit_month: "%B %d, %Y" date_with_hour: "%B %d, %Y %H:%M" + today: Today true: Yes unsplash: next: Next image diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 99b80a8739f2f4942c61a2f0c138dd5230ebc9df..623e0d9cd06b5b5cdb49ed1bfd9e474c21f5e9b3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -49,7 +49,7 @@ fr: status: Valeur héritée pending_tasks: label: Tâches en cours de traitement - hint: L'exécution de ces tâches contribue à diminuer l'empreinte carbone du numérique, en précalculant ce qui peut l'être. Cela peut générer un délai avant que vos modifications ne soient visibles. + hint: L'exécution de ces tâches contribue à diminuer l'empreinte carbone du numérique, en précalculant ce qui peut l'être. Cela peut générer un délai avant que vos modifications ne soient visibles. password_hint: Laissez vide si vous ne souhaitez pas modifier le mot de passe. successfully_created_html: "<i>%{model}</i> a bien été créé(e)." successfully_destroyed_html: "<i>%{model}</i> a bien été détruit(e)." @@ -172,7 +172,6 @@ fr: defaults: language: "Sélectionnez une langue" person: "Sélectionnez une personne" - program: "Sélectionnez une formation" simple_form_password_with_hints: test_chars: "%{min_length} caractères min." show: Voir @@ -185,6 +184,7 @@ fr: date_only: "%d/%m/%Y" date_with_explicit_month: "%d %B %Y" date_with_hour: "%d %B %Y %H:%M" + today: Aujourd'hui true: Oui unsplash: next: Images suivantes diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index 6de579a94b3757e9ee037e4de09bc694fe85c1ad..0b9428754ec7732aa4a2ed16aefab64f472ac007 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -55,7 +55,8 @@ en: url: Website user: User university/person/experience: - today: Today + from_year: Start year + to_year: End year university/person/involvement: description: Mission (in this context) person: Person @@ -100,9 +101,9 @@ en: university/person/alumnus: one: Alumnus other: Alumni - university/person/Experience: - one: Experience - other: Experiences + university/person/experience: + one: Professional experience + other: Professional experiences university/organization: one: Organization other: Organizations @@ -131,6 +132,7 @@ en: twitter: "Example: osuny" include_blanks: defaults: + organization: Select organization year: Select year enums: university: @@ -147,6 +149,10 @@ en: manage_experiences: Manage experiences person: administrator_roles: Administrator roles - taught_programs: Taught programs + experience: + no_organization_hint_html: "If the organization is not in the list,<br>you can <a href=\"%{url}\">create it</a>" + no_organization_hint_no_access_html: "If the organization is not in the list,<br>you should ask to create it" + period: Period + taught_programs: Taught programs sso: SSO sso_key: SSO Key diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index af72d52d27263c1fea9d70bd08509b8f68cb6ebc..9cb44fa03cd0f59bb60b2dc71b4e48aa3193a4ee 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -55,7 +55,8 @@ fr: url: Site web user: Utilisateur university/person/experience: - today: Aujourd'hui + from_year: Année de début + to_year: Année de fin university/person/involvement: description: Mission (dans ce contexte) person: Personne @@ -100,9 +101,9 @@ fr: university/person/alumnus: one: Alumnus other: Alumni - university/person/Experience: - one: Expérience - other: Expériences + university/person/experience: + one: Expérience professionnelle + other: Expériences professionnelles university/organization: one: Organisation other: Organisations @@ -131,6 +132,7 @@ fr: twitter: "Exemple : osuny" include_blanks: defaults: + organization: Sélectionnez une organisation year: Sélectionnez une année enums: university: @@ -147,6 +149,10 @@ fr: manage_experiences: Gérer les expériences professionnelles person: administrator_roles: Rôles administratifs + experience: + no_organization_hint_html: "Si l'entreprise n'apparait pas dans la liste,<br>vous pouvez la <a href=\"%{url}\">créer</a>" + no_organization_hint_no_access_html: "Si l'entreprise n'apparait pas dans la liste,<br>il faut demander à la créer" + period: Période taught_programs: Formations enseignées sso: SSO sso_key: Clé sur le SSO diff --git a/config/routes/admin/university.rb b/config/routes/admin/university.rb index 8b8d2a3b5dafb9064928c2b76d84d7e06d98013a..3acfe622ec80685a2c9b57c8ab3f731f4e696c25 100644 --- a/config/routes/admin/university.rb +++ b/config/routes/admin/university.rb @@ -8,10 +8,10 @@ namespace :university do end resources :alumni, only: [:index, :show] do member do - get 'edit_cohorts' => 'alumni#edit_cohorts' - patch 'edit_cohorts' => 'alumni#update_cohorts' - get 'edit_experience' => 'alumni#edit_experiences' - patch 'edit_experiences' => 'alumni#update_experiences' + get 'cohorts' => 'alumni/cohorts#edit' + patch 'cohorts' => 'alumni/cohorts#update' + get 'experiences' => 'alumni/experiences#edit' + patch 'experiences' => 'alumni/experiences#update' end end resources :people, :organizations