From 0c3d7870dee284f71248f3937dbaf810b2d83b11 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Tue, 5 Sep 2023 20:59:23 +0200 Subject: [PATCH] publishing --- app/models/communication/website.rb | 1 + .../communication/website/agenda/event.rb | 15 ++++ .../website/page/communication_agenda.rb | 70 +++++++++++++++++++ .../communication/website/page/with_type.rb | 1 + config/locales/communication/en.yml | 3 + config/locales/communication/fr.yml | 3 + 6 files changed, 93 insertions(+) create mode 100644 app/models/communication/website/page/communication_agenda.rb diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 48e342be6..f9dc4898c 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -91,6 +91,7 @@ class Communication::Website < ApplicationRecord configs + pages.where(language_id: language_ids) + posts.where(language_id: language_ids) + + events.where(language_id: language_ids) + categories.where(language_id: language_ids) + menus.where(language_id: language_ids) + [about] diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb index e0be85eb0..e6d02ea18 100644 --- a/app/models/communication/website/agenda/event.rb +++ b/app/models/communication/website/agenda/event.rb @@ -58,6 +58,21 @@ class Communication::Website::Agenda::Event < ApplicationRecord scope :ordered, -> { order(from_day: :desc) } + validates_presence_of :from_day + + def git_path(website) + return unless website.id == communication_website_id && published + "#{git_path_content_prefix(website)}events/#{static_path}.html" + end + + def static_path + "#{from_day.year}/#{from_day.strftime "%Y-%m-%d"}-#{slug}" + end + + def template_static + "admin/communication/websites/agenda/events/static" + end + def to_s "#{title}" end diff --git a/app/models/communication/website/page/communication_agenda.rb b/app/models/communication/website/page/communication_agenda.rb new file mode 100644 index 000000000..d30481e86 --- /dev/null +++ b/app/models/communication/website/page/communication_agenda.rb @@ -0,0 +1,70 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# header_text :text +# kind :integer +# meta_description :text +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# summary :text +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid not null, indexed +# original_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_original_id (original_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_304f57360f (original_id => communication_website_pages.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::CommunicationAgenda < Communication::Website::Page + + def editable_width? + false + end + + def full_width_by_default? + true + end + + def is_necessary_for_website? + website.feature_agenda + end + + def dependencies + super + + [website.config_default_languages] + + website.events + end + + protected + + def current_git_path + @current_git_path ||= "#{git_path_prefix}events/_index.html" + end + +end diff --git a/app/models/communication/website/page/with_type.rb b/app/models/communication/website/page/with_type.rb index d264af369..0257d94c9 100644 --- a/app/models/communication/website/page/with_type.rb +++ b/app/models/communication/website/page/with_type.rb @@ -9,6 +9,7 @@ module Communication::Website::Page::WithType Communication::Website::Page::Home, # Global objects Communication::Website::Page::CommunicationPost, + Communication::Website::Page::CommunicationAgenda, Communication::Website::Page::Person, Communication::Website::Page::Organization, # Education diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 9515f05fa..476d99b35 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -798,6 +798,9 @@ en: communication_post: slug: posts title: Posts + communication_agenda: + slug: agenda + title: Agenda education_diploma: slug: diplomas title: Diplomas diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 6050bb39c..b5e5734f1 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -795,6 +795,9 @@ fr: communication_post: slug: actualites title: Actualités + communication_agenda: + slug: agenda + title: Agenda education_diploma: slug: diplomes title: "Diplômes" -- GitLab