Skip to content
Snippets Groups Projects
Unverified Commit 042c7c00 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

clean kinds

parent 78df93d4
No related branches found
No related tags found
No related merge requests found
...@@ -57,19 +57,7 @@ class Communication::Website::Menu::Item < ApplicationRecord ...@@ -57,19 +57,7 @@ class Communication::Website::Menu::Item < ApplicationRecord
category: 41, category: 41,
post: 42, post: 42,
volume: 61, volume: 61,
paper: 63, paper: 63
# Legacy (remove when no menu items remain with these kinds)
programs: 30,
diplomas: 32,
posts: 40,
organizations: 45,
persons: 50,
administrators: 51,
authors: 52,
researchers: 53,
teachers: 54,
volumes: 60,
papers: 62
}, _prefix: :kind }, _prefix: :kind
validates :title, presence: true validates :title, presence: true
...@@ -79,25 +67,14 @@ class Communication::Website::Menu::Item < ApplicationRecord ...@@ -79,25 +67,14 @@ class Communication::Website::Menu::Item < ApplicationRecord
def self.icon_for(kind) def self.icon_for(kind)
icons = { icons = {
'administrators' => Icon::UNIVERSITY_PERSON_ADMINISTRATORS,
'authors' => Icon::UNIVERSITY_PERSON,
'blank' => 'font', 'blank' => 'font',
'diploma' => Icon::EDUCATION_DIPLOMA, 'diploma' => Icon::EDUCATION_DIPLOMA,
'diplomas' => Icon::EDUCATION_DIPLOMA,
'posts' => Icon::COMMUNICATION_WEBSITE_POST,
'post' => Icon::COMMUNICATION_WEBSITE_POST, 'post' => Icon::COMMUNICATION_WEBSITE_POST,
'category' => Icon::COMMUNICATION_WEBSITE_POST, 'category' => Icon::COMMUNICATION_WEBSITE_POST,
'page' => Icon::COMMUNICATION_WEBSITE_PAGE, 'page' => Icon::COMMUNICATION_WEBSITE_PAGE,
'program' => Icon::EDUCATION_PROGRAM, 'program' => Icon::EDUCATION_PROGRAM,
'programs' => Icon::EDUCATION_PROGRAM,
'paper' => Icon::RESEARCH_LABORATORY, 'paper' => Icon::RESEARCH_LABORATORY,
'papers' => Icon::RESEARCH_LABORATORY,
'volumes' => Icon::RESEARCH_LABORATORY,
'volume' => Icon::RESEARCH_LABORATORY, 'volume' => Icon::RESEARCH_LABORATORY,
'researchers' => Icon::RESEARCH_RESEARCHER,
'organizations' => Icon::UNIVERSITY_ORGANIZATION,
'persons' => Icon::UNIVERSITY_PERSON,
'teachers' => Icon::EDUCATION_TEACHER,
'url' => 'globe', 'url' => 'globe',
} }
"fas fa-#{icons[kind]}" if icons.has_key? kind "fas fa-#{icons[kind]}" if icons.has_key? kind
......
...@@ -12,8 +12,6 @@ module Communication::Website::WithMenus ...@@ -12,8 +12,6 @@ module Communication::Website::WithMenus
def menu_item_kinds def menu_item_kinds
Communication::Website::Menu::Item.kinds.reject do |key, value| Communication::Website::Menu::Item.kinds.reject do |key, value|
# TODO: Supprimer quand les pages spéciales seront en kind=page
next true if ["programs", "diplomas", "posts", "organizations", "persons", "administrators", "authors", "researchers", "teachers", "volumes", "papers"].include?(key)
method_name = "menu_item_kind_#{key}?" method_name = "menu_item_kind_#{key}?"
respond_to?(method_name) && !public_send(method_name) respond_to?(method_name) && !public_send(method_name)
end end
......
class SetAboutFromMenuItemKind < ActiveRecord::Migration[7.0] class SetAboutFromMenuItemKind < ActiveRecord::Migration[7.0]
def change def change
mapping = { mapping = {
programs: Communication::Website::Page::EducationProgram, 30: Communication::Website::Page::EducationProgram,
diplomas: Communication::Website::Page::EducationDiploma, 32: Communication::Website::Page::EducationDiploma,
posts: Communication::Website::Page::CommunicationPost, 40: Communication::Website::Page::CommunicationPost,
organizations: Communication::Website::Page::Organization, 45: Communication::Website::Page::Organization,
persons: Communication::Website::Page::Person, 50: Communication::Website::Page::Person,
administrators: Communication::Website::Page::Administrator, 51: Communication::Website::Page::Administrator,
authors: Communication::Website::Page::Author, 52: Communication::Website::Page::Author,
researchers: Communication::Website::Page::Researcher, 53: Communication::Website::Page::Researcher,
teachers: Communication::Website::Page::Teacher, 54: Communication::Website::Page::Teacher,
volumes: Communication::Website::Page::ResearchVolume, 60: Communication::Website::Page::ResearchVolume,
papers: Communication::Website::Page::ResearchPaper 62: Communication::Website::Page::ResearchPaper
} }
websites = Communication::Website.where(id: Communication::Website::Menu::Item.where(kind: mapping.keys).distinct.pluck(:website_id)) websites = Communication::Website.where(id: Communication::Website::Menu::Item.where(kind: mapping.keys).distinct.pluck(:website_id))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment