Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program > Portfolio category + related categories #2339

Merged
merged 26 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
98ad481
add is_taxonomy to blog and agenda categories + set portfolio program…
SebouChu Oct 17, 2024
947ec4c
program related_categories
SebouChu Oct 17, 2024
2c8c76e
fix tests
SebouChu Oct 17, 2024
20c459e
category slug with ancestors
SebouChu Oct 17, 2024
f324fb2
harmonize taxonomies
SebouChu Oct 18, 2024
301a932
add as localized tree to program category l10ns
SebouChu Oct 18, 2024
7700f63
harmonisation !
SebouChu Oct 18, 2024
4af1c8b
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 18, 2024
13aa3b7
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 21, 2024
53e074e
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 21, 2024
64e506b
Merge branch 'main' into program-portfolio-categories
SebouChu Oct 28, 2024
f15b696
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 29, 2024
558690a
is_taxonomy
arnaudlevy Oct 29, 2024
9b82b69
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 29, 2024
052fd57
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 30, 2024
47911c9
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 31, 2024
b0516da
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 31, 2024
f94a17e
Merge branch 'main' into program-portfolio-categories
arnaudlevy Oct 31, 2024
9ec009c
Merge branch 'main' into program-portfolio-categories
SebouChu Oct 31, 2024
f462e8f
Merge branch 'main' into program-portfolio-categories
SebouChu Oct 31, 2024
e08e370
wip is_taxonomy in person and orga categories
SebouChu Oct 31, 2024
19b3d2b
static categories in orga and people
SebouChu Oct 31, 2024
461303c
fix permalink and git path + hugo_slug
SebouChu Oct 31, 2024
b515121
fix
SebouChu Oct 31, 2024
9352102
static versions
SebouChu Oct 31, 2024
e997244
Merge branch 'main' into program-portfolio-categories
SebouChu Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def breadcrumb
def category_params
params.require(:communication_website_agenda_category)
.permit(
:parent_id,
:is_taxonomy, :parent_id,
localizations_attributes: [
:id, :language_id,
:name, :meta_description, :summary, :slug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def breadcrumb
end

def categories
@website.agenda_categories
.ordered
@website.agenda_categories.ordered
end

def event_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def breadcrumb
def category_params
params.require(:communication_website_post_category)
.permit(
:parent_id,
:is_taxonomy, :parent_id,
localizations_attributes: [
:id, :name, :meta_description, :summary, :slug,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def breadcrumb

def category_params
params.require(:university_organization_category).permit(
:parent_id,
:is_taxonomy, :parent_id,
localizations_attributes: [
:id, :name, :slug, :language_id
]).merge(university_id: current_university.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def breadcrumb

def category_params
params.require(:university_person_category).permit(
:parent_id,
:is_taxonomy, :parent_id,
localizations_attributes: [
:id, :name, :slug, :language_id
]).merge(university_id: current_university.id)
Expand Down
11 changes: 2 additions & 9 deletions app/models/communication/website/agenda/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# id :uuid not null, primary key
# is_programs_root :boolean default(FALSE)
# is_taxonomy :boolean default(FALSE)
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
Expand All @@ -27,24 +28,16 @@
# fk_rails_7b5ad84dda (communication_website_id => communication_websites.id)
#
class Communication::Website::Agenda::Category < ApplicationRecord
include AsCategory
include AsDirectObject
include Localizable
include Orderable
include Sanitizable
include WithMenuItemTarget
include WithTree
include WithUniversity

belongs_to :parent,
class_name: 'Communication::Website::Agenda::Category',
optional: true
belongs_to :program,
class_name: 'Education::Program',
optional: true
has_many :children,
class_name: 'Communication::Website::Agenda::Category',
foreign_key: :parent_id,
dependent: :destroy
has_and_belongs_to_many :events,
class_name: 'Communication::Website::Agenda::Event',
join_table: :communication_website_agenda_events_categories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class Communication::Website::Agenda::Category::Localization < ApplicationRecord
before_validation :set_communication_website_id, on: :create

def git_path(website)
"#{git_path_content_prefix(website)}events_categories/#{slug}/_index.html"
prefix = git_path_content_prefix(website)
slugs = slug_with_ancestors_slugs(separator: '-')
"#{prefix}events_categories/#{slugs}/_index.html"
end

def template_static
Expand Down Expand Up @@ -95,4 +97,9 @@ def inherited_blob_ids
def set_communication_website_id
self.communication_website_id ||= about.communication_website_id
end

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end
end
2 changes: 1 addition & 1 deletion app/models/communication/website/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def to_s
end

def git_path(website)
"data/menus/#{language.iso_code}/#{identifier}.yml"
"data/menus/#{language.iso_code}/#{identifier}.yml" if website.active_language_ids.include?(language_id)
end

def template_static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def published?

def substitutions
{
slug: about.slug
slug: about.slug_with_ancestors_slugs
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.special_page_type

def substitutions
{
slug: about.slug
slug: about.slug_with_ancestors_slugs
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.special_page_type

def substitutions
{
slug: about.slug
slug: about.slug_with_ancestors_slugs
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def published?

def substitutions
{
slug: about.slug
slug: about.slug_with_ancestors_slugs
}
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/communication/website/portfolio/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def references
[parent]
end

def siblings
self.class.unscoped.where(parent: parent, university: university, website: website).where.not(id: id)
end

protected

def last_ordered_element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class Communication::Website::Portfolio::Category::Localization < ApplicationRec
before_validation :set_communication_website_id, on: :create

def git_path(website)
"#{git_path_content_prefix(website)}projects_categories/#{slug}/_index.html"
prefix = git_path_content_prefix(website)
slugs = slug_with_ancestors_slugs(separator: '-')
"#{prefix}projects_categories/#{slugs}/_index.html"
end

def template_static
Expand Down Expand Up @@ -86,4 +88,9 @@ def slug_unavailable?(slug)
def set_communication_website_id
self.communication_website_id ||= about.communication_website_id
end

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end
end
11 changes: 2 additions & 9 deletions app/models/communication/website/post/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# id :uuid not null, primary key
# is_programs_root :boolean default(FALSE)
# is_taxonomy :boolean default(FALSE)
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
Expand All @@ -27,24 +28,16 @@
# fk_rails_e58348b119 (program_id => education_programs.id)
#
class Communication::Website::Post::Category < ApplicationRecord
include AsCategory
include AsDirectObject
include Localizable
include Orderable
include Sanitizable
include WithMenuItemTarget
include WithTree
include WithUniversity

belongs_to :parent,
class_name: 'Communication::Website::Post::Category',
optional: true
belongs_to :program,
class_name: 'Education::Program',
optional: true
has_many :children,
class_name: 'Communication::Website::Post::Category',
foreign_key: :parent_id,
dependent: :destroy
has_and_belongs_to_many :posts,
class_name: 'Communication::Website::Post',
join_table: :communication_website_categories_posts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ def inherited_blob_ids
def set_communication_website_id
self.communication_website_id ||= about.communication_website_id
end

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def set_programs_categories
end

def set_programs_categories_safely
[post_categories, agenda_categories].each do |objects|
[post_categories, agenda_categories, portfolio_categories].each do |objects|
programs_root_category = set_programs_categories_root_for!(objects)
set_programs_categories_at_level_for! objects, programs_root_category, education_programs.root.ordered
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/education/program/category/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#
class Education::Program::Category::Localization < ApplicationRecord
include AsLocalization
include AsLocalizedTree
include Contentful
include Initials
include Permalinkable
Expand All @@ -49,4 +50,11 @@ def dependencies
def to_s
"#{name}"
end

protected

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end
end
20 changes: 15 additions & 5 deletions app/models/education/program/with_websites_categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ module Education::Program::WithWebsitesCategories
included do
after_save_commit :set_websites_categories

has_many :website_post_categories,
class_name: 'Communication::Website::Post::Category',
dependent: :destroy

has_many :website_agenda_categories,
class_name: 'Communication::Website::Agenda::Category',
dependent: :destroy

# TODO : Ajouter les catégories de portfolio
has_many :website_portfolio_categories,
class_name: 'Communication::Website::Portfolio::Category',
dependent: :destroy

has_many :website_post_categories,
class_name: 'Communication::Website::Post::Category',
dependent: :destroy
end

def set_websites_categories
websites.each { |website| website.set_programs_categories }
end

def website_category_l10ns_for(website, language)
categories = {}
categories[:agenda] = website_agenda_categories.find_by(communication_website_id: website.id)&.localization_for(language)
categories[:blog] = website_post_categories.find_by(communication_website_id: website.id)&.localization_for(language)
categories[:portfolio] = website_portfolio_categories.find_by(communication_website_id: website.id)&.localization_for(language)
categories.compact
end
end
11 changes: 2 additions & 9 deletions app/models/university/organization/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: university_organization_categories
#
# id :uuid not null, primary key
# is_taxonomy :boolean default(FALSE)
# position :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
Expand All @@ -20,19 +21,11 @@
# fk_rails_f610c7eb13 (university_id => universities.id)
#
class University::Organization::Category < ApplicationRecord
include AsCategory
include AsIndirectObject
include Localizable
include Orderable
include WithTree
include WithUniversity

belongs_to :parent,
class_name: 'University::Organization::Category',
optional: true
has_many :children,
class_name: 'University::Organization::Category',
foreign_key: :parent_id,
dependent: :destroy
has_and_belongs_to_many :organizations,
class_name: 'University::Organization',
join_table: :university_organizations_categories
Expand Down
10 changes: 9 additions & 1 deletion app/models/university/organization/category/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def dependencies
end

def git_path(website)
"#{git_path_content_prefix(website)}organizations_categories/#{slug}/_index.html" if for_website?(website)
return unless for_website?(website)
prefix = git_path_content_prefix(website)
slugs = slug_with_ancestors_slugs(separator: '-')
"#{prefix}organizations_categories/#{slugs}/_index.html"
end

def template_static
Expand All @@ -56,4 +59,9 @@ def published?
persisted?
end

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end

end
11 changes: 2 additions & 9 deletions app/models/university/person/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: university_person_categories
#
# id :uuid not null, primary key
# is_taxonomy :boolean default(FALSE)
# position :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
Expand All @@ -20,19 +21,11 @@
# fk_rails_4c00a79930 (parent_id => university_person_categories.id)
#
class University::Person::Category < ApplicationRecord
include AsCategory
include AsIndirectObject
include Localizable
include Orderable
include WithTree
include WithUniversity

belongs_to :parent,
class_name: 'University::Person::Category',
optional: true
has_many :children,
class_name: 'University::Person::Category',
foreign_key: :parent_id,
dependent: :destroy
has_and_belongs_to_many :people,
class_name: 'University::Person',
join_table: :university_people_categories
Expand Down
10 changes: 9 additions & 1 deletion app/models/university/person/category/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def dependencies
end

def git_path(website)
"#{git_path_content_prefix(website)}persons_categories/#{slug}/_index.html" if for_website?(website)
return unless for_website?(website)
prefix = git_path_content_prefix(website)
slugs = slug_with_ancestors_slugs(separator: '-')
"#{prefix}persons_categories/#{slugs}/_index.html"
end

def template_static
Expand All @@ -56,4 +59,9 @@ def published?
persisted?
end

# TODO : Pertinent ?
def hugo_slug_in_website(website)
slug_with_ancestors_slugs(separator: '-')
end

end
Loading
Loading