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..bf2282641ebaa592bc1b6da0ee9cf130091a6176 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 @@ -46,6 +46,7 @@ module Communication::Website::WithSpecialPages published: true, university_id: university_id ) + page.sync_with_git 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/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/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