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
category: 41,
post: 42,
volume: 61,
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
paper: 63
}, _prefix: :kind
validates :title, presence: true
......@@ -79,25 +67,14 @@ class Communication::Website::Menu::Item < ApplicationRecord
def self.icon_for(kind)
icons = {
'administrators' => Icon::UNIVERSITY_PERSON_ADMINISTRATORS,
'authors' => Icon::UNIVERSITY_PERSON,
'blank' => 'font',
'diploma' => Icon::EDUCATION_DIPLOMA,
'diplomas' => Icon::EDUCATION_DIPLOMA,
'posts' => Icon::COMMUNICATION_WEBSITE_POST,
'post' => Icon::COMMUNICATION_WEBSITE_POST,
'category' => Icon::COMMUNICATION_WEBSITE_POST,
'page' => Icon::COMMUNICATION_WEBSITE_PAGE,
'program' => Icon::EDUCATION_PROGRAM,
'programs' => Icon::EDUCATION_PROGRAM,
'paper' => Icon::RESEARCH_LABORATORY,
'papers' => Icon::RESEARCH_LABORATORY,
'volumes' => 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',
}
"fas fa-#{icons[kind]}" if icons.has_key? kind
......
......@@ -12,8 +12,6 @@ module Communication::Website::WithMenus
def menu_item_kinds
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}?"
respond_to?(method_name) && !public_send(method_name)
end
......
class SetAboutFromMenuItemKind < ActiveRecord::Migration[7.0]
def change
mapping = {
programs: Communication::Website::Page::EducationProgram,
diplomas: Communication::Website::Page::EducationDiploma,
posts: Communication::Website::Page::CommunicationPost,
organizations: Communication::Website::Page::Organization,
persons: Communication::Website::Page::Person,
administrators: Communication::Website::Page::Administrator,
authors: Communication::Website::Page::Author,
researchers: Communication::Website::Page::Researcher,
teachers: Communication::Website::Page::Teacher,
volumes: Communication::Website::Page::ResearchVolume,
papers: Communication::Website::Page::ResearchPaper
30: Communication::Website::Page::EducationProgram,
32: Communication::Website::Page::EducationDiploma,
40: Communication::Website::Page::CommunicationPost,
45: Communication::Website::Page::Organization,
50: Communication::Website::Page::Person,
51: Communication::Website::Page::Administrator,
52: Communication::Website::Page::Author,
53: Communication::Website::Page::Researcher,
54: Communication::Website::Page::Teacher,
60: Communication::Website::Page::ResearchVolume,
62: Communication::Website::Page::ResearchPaper
}
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