From 60d283ee84cba98c60c98fe18133ceb4b50dd82d Mon Sep 17 00:00:00 2001
From: pabois <pierreandre.boissinot@noesya.coop>
Date: Mon, 9 Jan 2023 14:42:04 +0100
Subject: [PATCH] change category text to summary

---
 .../communication/websites/categories_controller.rb    |  2 +-
 app/models/communication/website/category.rb           |  2 +-
 .../communication/websites/categories/_form.html.erb   |  2 +-
 .../communication/websites/categories/show.html.erb    | 10 +---------
 .../communication/websites/categories/static.html.erb  |  3 +--
 config/locales/communication/en.yml                    |  2 +-
 config/locales/communication/fr.yml                    |  2 +-
 ...20230109132016_rename_categories_text_to_summary.rb |  5 +++++
 db/schema.rb                                           |  4 ++--
 9 files changed, 14 insertions(+), 18 deletions(-)
 create mode 100644 db/migrate/20230109132016_rename_categories_text_to_summary.rb

diff --git a/app/controllers/admin/communication/websites/categories_controller.rb b/app/controllers/admin/communication/websites/categories_controller.rb
index 580c9497c..e2c6aefe9 100644
--- a/app/controllers/admin/communication/websites/categories_controller.rb
+++ b/app/controllers/admin/communication/websites/categories_controller.rb
@@ -97,7 +97,7 @@ class Admin::Communication::Websites::CategoriesController < Admin::Communicatio
   def category_params
     params.require(:communication_website_category)
           .permit(
-            :website_id, :name, :description, :text, :slug, :parent_id,
+            :website_id, :name, :description, :summary, :slug, :parent_id,
             :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit
           )
           .merge(university_id: current_university.id)
diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb
index 1d3d87c76..d6d6174e7 100644
--- a/app/models/communication/website/category.rb
+++ b/app/models/communication/website/category.rb
@@ -12,7 +12,7 @@
 #  path                     :string
 #  position                 :integer
 #  slug                     :string
-#  text                     :text
+#  summary                  :text
 #  created_at               :datetime         not null
 #  updated_at               :datetime         not null
 #  communication_website_id :uuid             not null, indexed
diff --git a/app/views/admin/communication/websites/categories/_form.html.erb b/app/views/admin/communication/websites/categories/_form.html.erb
index ca666d406..3ac988a84 100644
--- a/app/views/admin/communication/websites/categories/_form.html.erb
+++ b/app/views/admin/communication/websites/categories/_form.html.erb
@@ -10,7 +10,7 @@
         </div>
         <div class="card-body">
           <%= f.input :name %>
-          <%= f.input :text %>
+          <%= render 'admin/application/summary/form', f: f, about: category %>
         </div>
       </div>
       <div class="card">
diff --git a/app/views/admin/communication/websites/categories/show.html.erb b/app/views/admin/communication/websites/categories/show.html.erb
index 851734a6c..119b03aec 100644
--- a/app/views/admin/communication/websites/categories/show.html.erb
+++ b/app/views/admin/communication/websites/categories/show.html.erb
@@ -3,15 +3,7 @@
 <%= render 'admin/communication/websites/sidebar' do %>
   <div class="row">
     <div class="col-md-8">
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h2 class="card-title mb-0 h5"><%= t('content') %></h2>
-        </div>
-        <div class="card-body">
-          <h3 class="h5"><%= Communication::Website::Category.human_attribute_name('text') %></h3>
-          <%= sanitize @category.text %>
-        </div>
-      </div>
+      <%= render 'admin/application/summary/show', about: @category %>
       <%= render 'admin/communication/blocks/list', about: @category %>
     </div>
     <div class="col-md-4">
diff --git a/app/views/admin/communication/websites/categories/static.html.erb b/app/views/admin/communication/websites/categories/static.html.erb
index 21d8a6f55..00c8b304b 100644
--- a/app/views/admin/communication/websites/categories/static.html.erb
+++ b/app/views/admin/communication/websites/categories/static.html.erb
@@ -15,7 +15,6 @@ position: <%= @about.position %>
 <%= render 'admin/communication/unsplash/static' %>
 description: >
   <%= prepare_text_for_static @about.description %>
-description_short: >
-  <%= prepare_text_for_static @about.text %>
+<%= render 'admin/application/summary/static' %>
 <%= render 'admin/communication/blocks/static', about: @about %>
 ---
diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml
index 1a29bf58b..5376cfd59 100644
--- a/config/locales/communication/en.yml
+++ b/config/locales/communication/en.yml
@@ -85,12 +85,12 @@ en:
       communication/website/category:
         children: Children categories
         description: Meta Description
-        text: Lead text
         featured_image: Featured image
         featured_image_alt: Alt text
         name: Name
         parent: Parent category
         slug: Slug
+        summary: Summary
       communication/website/imported/category:
         original: Original
       communication/website/imported/medium:
diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml
index 57a6f9004..d93f91404 100644
--- a/config/locales/communication/fr.yml
+++ b/config/locales/communication/fr.yml
@@ -85,12 +85,12 @@ fr:
       communication/website/category:
         children: Catégories enfants
         description: Meta Description
-        text: Chapô
         featured_image: Image à la une
         featured_image_alt: Texte alternatif
         name: Nom
         parent: Catégorie parente
         slug: Slug
+        summary: Résumé
       communication/website/imported/category:
         original: Original
       communication/website/imported/medium:
diff --git a/db/migrate/20230109132016_rename_categories_text_to_summary.rb b/db/migrate/20230109132016_rename_categories_text_to_summary.rb
new file mode 100644
index 000000000..acbd8d5a8
--- /dev/null
+++ b/db/migrate/20230109132016_rename_categories_text_to_summary.rb
@@ -0,0 +1,5 @@
+class RenameCategoriesTextToSummary < ActiveRecord::Migration[7.0]
+  def change
+    rename_column :communication_website_categories, :text, :summary
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8573f604d..abc4d3959 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[7.0].define(version: 2023_01_09_110701) do
+ActiveRecord::Schema[7.0].define(version: 2023_01_09_132016) do
   # These are extensions that must be enabled in order to support this database
   enable_extension "pgcrypto"
   enable_extension "plpgsql"
@@ -132,7 +132,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_110701) do
     t.boolean "is_programs_root", default: false
     t.string "path"
     t.string "featured_image_alt"
-    t.text "text"
+    t.text "summary"
     t.text "featured_image_credit"
     t.index ["communication_website_id"], name: "idx_communication_website_post_cats_on_communication_website_id"
     t.index ["parent_id"], name: "index_communication_website_categories_on_parent_id"
-- 
GitLab