diff --git a/app/controllers/admin/communication/website/pages_controller.rb b/app/controllers/admin/communication/website/pages_controller.rb index 7440eaedf4859bba19f61fdd0be3b97867ee8717..26aa3f068d18579169652aaa42d77c93c3a0adcf 100644 --- a/app/controllers/admin/communication/website/pages_controller.rb +++ b/app/controllers/admin/communication/website/pages_controller.rb @@ -87,7 +87,7 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web def page_params params.require(:communication_website_page) .permit(:communication_website_id, :title, :breadcrumb_title, - :description, :description_short, :header_text, :text, :about_type, :about_id, :slug, :published, + :description, :description_short, :header_text, :text, :slug, :published, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :parent_id, :related_category_id) .merge(university_id: current_university.id) diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 35ef585c6e27796ba6ae6201b284b4363587012d..ce85a34e592788a6605de2184a0899b5a8e02f18 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -55,7 +55,7 @@ class Communication::Website < ApplicationRecord dependencies = [self, config_permalinks, config_base_url] + menus dependencies += pages + pages.map(&:active_storage_blobs).flatten dependencies += posts + posts.map(&:active_storage_blobs).flatten if has_communication_posts? - dependencies += people_with_facets + people.map(&:active_storage_blobs).flatten if has_people? + dependencies += people_with_facets + people.map(&:active_storage_blobs).flatten if has_persons? dependencies += [categories] if has_communication_categories? dependencies += about.git_dependencies(website) dependencies diff --git a/app/models/communication/website/menu/item/with_targets.rb b/app/models/communication/website/menu/item/with_targets.rb index efb75d88c2559ebee6a88c3957c615d450f0cec2..c70f22afe5966e5ceb484c0340771be73b23d7cc 100644 --- a/app/models/communication/website/menu/item/with_targets.rb +++ b/app/models/communication/website/menu/item/with_targets.rb @@ -36,7 +36,7 @@ module Communication::Website::Menu::Item::WithTargets end def target_for_staff - "#{website.special_page(:people).path}" + "#{website.special_page(:persons).path}" end def target_for_administrators diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index cf50261f840450112b1cde7c57971b9b422d62ab..93672d9ea9149b4bc813c2833df478124056c28a 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -3,7 +3,6 @@ # Table name: communication_website_pages # # id :uuid not null, primary key -# about_type :string indexed => [about_id] # breadcrumb_title :string # description :text # description_short :text @@ -11,7 +10,6 @@ # github_path :text # header_text :text # kind :integer -# old_text :text # path :text # position :integer default(0), not null # published :boolean default(FALSE) @@ -20,7 +18,6 @@ # title :string # created_at :datetime not null # updated_at :datetime not null -# about_id :uuid indexed => [about_type] # communication_website_id :uuid not null, indexed # parent_id :uuid indexed # related_category_id :uuid indexed @@ -28,7 +25,6 @@ # # Indexes # -# index_communication_website_pages_on_about (about_type,about_id) # index_communication_website_pages_on_communication_website_id (communication_website_id) # index_communication_website_pages_on_parent_id (parent_id) # index_communication_website_pages_on_related_category_id (related_category_id) @@ -88,7 +84,12 @@ class Communication::Website::Page < ApplicationRecord end def git_path(website) - "content/pages/#{path}/_index.html" if published + return unless published + if is_special_page? && SPECIAL_PAGES_WITH_GIT_SPECIAL_PATH.include?(kind) + "content/#{kind.split('_').last}/_index.html" + else + "content/pages/#{path}/_index.html" + end end def git_dependencies(website) diff --git a/app/models/communication/website/page/with_kind.rb b/app/models/communication/website/page/with_kind.rb index 022acc8ba9bc1f32be0778189a7846727f196b73..667926934fe5380a9498a4679e9ac6ed815ec718 100644 --- a/app/models/communication/website/page/with_kind.rb +++ b/app/models/communication/website/page/with_kind.rb @@ -12,13 +12,25 @@ module Communication::Website::Page::WithKind legal_terms: 80, sitemap: 81, privacy_policy: 82, - people: 100, + persons: 100, administrators: 110, authors: 120, researchers: 130, teachers: 140 }, _prefix: 'kind' + SPECIAL_PAGES_WITH_GIT_SPECIAL_PATH = [ + 'communication_posts', + 'education_programs', + 'research_articles', + 'research_volumes', + 'persons', + 'administrators', + 'authors', + 'researchers', + 'teachers' + ].freeze + after_create :move_legacy_root_pages, if: :kind_home? def is_special_page? diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index ec9e66e7b08a8ec3db1c0c0a2a73aa7be218f550..2910fa4942632f594ed895395a0ce4ab34de648d 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -7,7 +7,6 @@ # description_short :text # featured_image_alt :string # github_path :text -# old_text :text # pinned :boolean default(FALSE) # published :boolean default(FALSE) # published_at :datetime diff --git a/app/models/communication/website/with_dependencies.rb b/app/models/communication/website/with_dependencies.rb index 66953a0330e52edbd529fd1a9127bb685c493ea7..8e490602eac308b2d1c1ab9111ad3c29c71051a0 100644 --- a/app/models/communication/website/with_dependencies.rb +++ b/app/models/communication/website/with_dependencies.rb @@ -104,7 +104,7 @@ module Communication::Website::WithDependencies authors.compact.any? end - def has_people? + def has_persons? has_authors? || has_administrators? || has_researchers? || has_teachers? end diff --git a/app/models/communication/website/with_menu_items.rb b/app/models/communication/website/with_menu_items.rb index 6aefcc20c775a0187eaa31be77acaf452d3d2105..51818072c81d59137a0d1f35bc47f1c359479524 100644 --- a/app/models/communication/website/with_menu_items.rb +++ b/app/models/communication/website/with_menu_items.rb @@ -41,7 +41,7 @@ module Communication::Website::WithMenuItems end def menu_item_kind_staff? - has_people? + has_persons? end def menu_item_kind_administrators? diff --git a/app/models/communication/website/with_special_pages.rb b/app/models/communication/website/with_special_pages.rb index b0e725248cf3d254fddeffea1a848b2e0035dcd2..e3e41bc2f276b945b69088aed17c3396ad37f791 100644 --- a/app/models/communication/website/with_special_pages.rb +++ b/app/models/communication/website/with_special_pages.rb @@ -17,10 +17,10 @@ module Communication::Website::WithSpecialPages create_special_page(kind, homepage.id) if public_send("has_#{kind}?") end # team pages - if has_people? - people = create_special_page('people', homepage.id) + if has_persons? + persons = create_special_page('persons', homepage.id) ['administrators', 'authors', 'researchers', 'teachers'].each do |kind| - create_special_page(kind, people.id) if public_send("has_#{kind}?") + create_special_page(kind, persons.id) if public_send("has_#{kind}?") end end end @@ -34,12 +34,12 @@ module Communication::Website::WithSpecialPages end - # private + private def create_special_page(kind, parent_id = nil) i18n_key = "communication.website.pages.defaults.#{kind}" # TODO: remove legacy after migrations - legacy_index_page = Communication::Website::IndexPage.where(communication_website_id: Communication::Website.first.id, kind: kind == 'people' ? 'persons' : kind).first + legacy_index_page = Communication::Website::IndexPage.where(communication_website_id: Communication::Website.first.id, kind: kind).first if legacy_index_page.present? page = pages.where(kind: kind).first unless page.present? diff --git a/app/views/admin/communication/website/configs/permalinks/static.html.erb b/app/views/admin/communication/website/configs/permalinks/static.html.erb index 693685c4fb26f83c24c313796c8ca3feb3a259a7..f92b0bae0a18feb5ee151e49c1c1abca33a648c8 100644 --- a/app/views/admin/communication/website/configs/permalinks/static.html.erb +++ b/app/views/admin/communication/website/configs/permalinks/static.html.erb @@ -4,19 +4,19 @@ posts: <%= @website.special_page(:communication_posts).path %>/:year/:m <% if @website.has_communication_categories? %> categories: <%= @website.special_page(:communication_posts).path %>/:slug/ <% end %> -<% if @website.has_people? %> -persons: <%= @website.special_page(:people).path %>/:slug/ +<% if @website.has_persons? %> +persons: <%= @website.special_page(:persons).path %>/:slug/ <% end %> <% if @website.has_authors? %> -authors: /<%= @website.special_page(:people).path %>/:slug/<%= @website.special_page(:communication_posts).slug %>/ +authors: /<%= @website.special_page(:persons).path %>/:slug/<%= @website.special_page(:communication_posts).slug %>/ <% end %> <%# ces paths complémentaires sont nécessairesà Hugo mais on ne les utilise pas %> <% if @website.has_administrators? %> -administrators: /<%= @website.special_page(:people).path %>/:slug/roles/ +administrators: /<%= @website.special_page(:persons).path %>/:slug/roles/ <% end %> <% if @website.has_teachers? %> -teachers: /<%= @website.special_page(:people).path %>/:slug/programs/ +teachers: /<%= @website.special_page(:persons).path %>/:slug/programs/ <% end %> <% if @website.has_researchers? %> -researchers: /<%= @website.special_page(:people).path %>/:slug/articles/ +researchers: /<%= @website.special_page(:persons).path %>/:slug/articles/ <% end %> diff --git a/db/migrate/20220408080633_remove_about_from_communication_website_pages.rb b/db/migrate/20220408080633_remove_about_from_communication_website_pages.rb new file mode 100644 index 0000000000000000000000000000000000000000..102ed58367cf33f7a018287344741f7aa4e0925f --- /dev/null +++ b/db/migrate/20220408080633_remove_about_from_communication_website_pages.rb @@ -0,0 +1,6 @@ +class RemoveAboutFromCommunicationWebsitePages < ActiveRecord::Migration[6.1] + def change + remove_column :communication_website_pages, :about_type + remove_column :communication_website_pages, :about_id + end +end diff --git a/db/migrate/20220408080927_remove_old_text_from_communication_website_pages_and_posts.rb b/db/migrate/20220408080927_remove_old_text_from_communication_website_pages_and_posts.rb new file mode 100644 index 0000000000000000000000000000000000000000..38a2a607071c8ef31b6ce3058d634eb5734cff03 --- /dev/null +++ b/db/migrate/20220408080927_remove_old_text_from_communication_website_pages_and_posts.rb @@ -0,0 +1,6 @@ +class RemoveOldTextFromCommunicationWebsitePagesAndPosts < ActiveRecord::Migration[6.1] + def change + remove_column :communication_website_pages, :old_text + remove_column :communication_website_posts, :old_text + end +end diff --git a/db/schema.rb b/db/schema.rb index 4039e1e37467bf6c3ba6f4b16ab9a34e8e142bf9..84dbb44f95c6470bc4f492e20662d4f27747a3b6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_04_04_140813) do +ActiveRecord::Schema.define(version: 2022_04_08_080927) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -309,11 +309,8 @@ ActiveRecord::Schema.define(version: 2022_04_04_140813) do t.text "path" t.uuid "parent_id" t.integer "position", default: 0, null: false - t.string "about_type" - t.uuid "about_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.text "old_text" t.boolean "published", default: false t.text "github_path" t.uuid "related_category_id" @@ -323,7 +320,6 @@ ActiveRecord::Schema.define(version: 2022_04_04_140813) do t.string "breadcrumb_title" t.text "header_text" t.integer "kind" - t.index ["about_type", "about_id"], name: "index_communication_website_pages_on_about" t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id" t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id" t.index ["related_category_id"], name: "index_communication_website_pages_on_related_category_id" @@ -335,7 +331,6 @@ ActiveRecord::Schema.define(version: 2022_04_04_140813) do t.uuid "communication_website_id", null: false t.string "title" t.text "description" - t.text "old_text" t.boolean "published", default: false t.datetime "published_at" t.datetime "created_at", precision: 6, null: false diff --git a/test/fixtures/communication/website/posts.yml b/test/fixtures/communication/website/posts.yml index 0bc85c0f7d3a8fd095a209660748ede658f845ff..e1a8f8962b8bafba9698d1b75a7ff3e6f095db49 100644 --- a/test/fixtures/communication/website/posts.yml +++ b/test/fixtures/communication/website/posts.yml @@ -7,7 +7,6 @@ # description_short :text # featured_image_alt :string # github_path :text -# old_text :text # pinned :boolean default(FALSE) # published :boolean default(FALSE) # published_at :datetime