From 0cd236a5b6b0602657b2ec228dbeb69ed943a7ca Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Thu, 19 May 2022 12:06:09 +0200 Subject: [PATCH] remove related category for pages (replaces by blocks) --- .../admin/communication/websites/pages_controller.rb | 2 +- app/models/communication/website/page.rb | 6 ------ .../admin/communication/websites/pages/_form.html.erb | 4 ---- .../admin/communication/websites/pages/show.html.erb | 9 --------- .../admin/communication/websites/pages/static.html.erb | 3 --- .../20220519100506_remove_pages_related_category_id.rb | 5 +++++ db/schema.rb | 5 +---- 7 files changed, 7 insertions(+), 27 deletions(-) create mode 100644 db/migrate/20220519100506_remove_pages_related_category_id.rb diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index d4bb7ed16..f4065516d 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -91,7 +91,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We :communication_website_id, :title, :breadcrumb_title, :bodyclass, :description, :description_short, :header_text, :text, :slug, :published, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, - :parent_id, :related_category_id, :language_id + :parent_id, :language_id ) .merge(university_id: current_university.id) end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 0a8959ca6..bdb083c2a 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -23,7 +23,6 @@ # communication_website_id :uuid not null, indexed # language_id :uuid indexed # parent_id :uuid indexed -# related_category_id :uuid indexed # university_id :uuid not null, indexed # # Indexes @@ -31,14 +30,12 @@ # 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_parent_id (parent_id) -# index_communication_website_pages_on_related_category_id (related_category_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_47b37cf8b2 (related_category_id => communication_website_categories.id) # fk_rails_d208d15a73 (university_id => universities.id) # @@ -58,9 +55,6 @@ class Communication::Website::Page < ApplicationRecord belongs_to :website, foreign_key: :communication_website_id - belongs_to :related_category, - class_name: 'Communication::Website::Category', - optional: true belongs_to :parent, class_name: 'Communication::Website::Page', optional: true diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index f2c2e2064..00d096e51 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -14,10 +14,6 @@ <%= f.input :description_short, input_html: { value: page.description_short&.gsub('&', '&') } %> <%= f.input :header_text, as: :string %> <%= f.input :text, as: :summernote if page.text&.to_plain_text.present? %> - <%= f.association :related_category, - collection: collection_tree(@website.categories), - label_method: ->(p) { sanitize p[:label] }, - value_method: ->(p) { p[:id] } if @website.categories.any? && page.is_regular_page? %> </div> </div> <div class="card"> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index c8f577339..6241359b1 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -71,15 +71,6 @@ </p> <% end %> - <% if @page.related_category %> - <h3 class="h5"><%= Communication::Website::Page.human_attribute_name('related_category') %></h3> - <p><%= link_to_if can?(:read, @page.related_category), - @page.related_category, - admin_communication_website_category_path( - website_id: @website.id, - id: @page.related_category.id - ) %></p> - <% end %> <% if @page.children.any? %> <h3 class="h5"><%= Communication::Website::Page.human_attribute_name('children') %></h3> <ul class="list-unstyled mb-0"> diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index 710adbec9..e9c8061ee 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -12,9 +12,6 @@ children: - <%= child.path %> <% end %> <% end %> -<% if @about.related_category %> -category: "<%= @about.related_category.path %>" -<% end %> description: > <%= prepare_text_for_static @about.description %> description_short: > diff --git a/db/migrate/20220519100506_remove_pages_related_category_id.rb b/db/migrate/20220519100506_remove_pages_related_category_id.rb new file mode 100644 index 000000000..c23410315 --- /dev/null +++ b/db/migrate/20220519100506_remove_pages_related_category_id.rb @@ -0,0 +1,5 @@ +class RemovePagesRelatedCategoryId < ActiveRecord::Migration[6.1] + def change + remove_column :communication_website_pages, :related_category_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 931135610..be781469c 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_05_16_095044) do +ActiveRecord::Schema.define(version: 2022_05_19_100506) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -300,7 +300,6 @@ ActiveRecord::Schema.define(version: 2022_05_16_095044) do t.datetime "updated_at", precision: 6, null: false t.boolean "published", default: false t.text "github_path" - t.uuid "related_category_id" t.string "featured_image_alt" t.text "text" t.text "description_short" @@ -313,7 +312,6 @@ ActiveRecord::Schema.define(version: 2022_05_16_095044) do t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id" t.index ["language_id"], name: "index_communication_website_pages_on_language_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" t.index ["university_id"], name: "index_communication_website_pages_on_university_id" end @@ -828,7 +826,6 @@ ActiveRecord::Schema.define(version: 2022_05_16_095044) do add_foreign_key "communication_website_menu_items", "universities" add_foreign_key "communication_website_menus", "communication_websites" add_foreign_key "communication_website_menus", "universities" - add_foreign_key "communication_website_pages", "communication_website_categories", column: "related_category_id" add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id" add_foreign_key "communication_website_pages", "communication_websites" add_foreign_key "communication_website_pages", "universities" -- GitLab