From 2c07984ebbd2d5e3537fd9891e30db96a5934e9b Mon Sep 17 00:00:00 2001
From: Arnaud Levy <arnaud.levy@noesya.coop>
Date: Tue, 12 Nov 2024 15:14:49 +0100
Subject: [PATCH] Full widh posts (#2413)

---
 .../websites/posts_controller.rb              |  2 +-
 .../websites/posts/_form.html.erb             |  1 +
 .../websites/posts/static.html.erb            |  6 +--
 config/locales/communication/en.yml           |  2 +
 config/locales/communication/fr.yml           |  2 +
 ...4_add_full_width_to_communication_posts.rb |  5 +++
 db/schema.rb                                  | 40 +++++++++++++++++--
 7 files changed, 48 insertions(+), 10 deletions(-)
 create mode 100644 db/migrate/20241112132644_add_full_width_to_communication_posts.rb

diff --git a/app/controllers/admin/communication/websites/posts_controller.rb b/app/controllers/admin/communication/websites/posts_controller.rb
index 218f0c828..28286de7f 100644
--- a/app/controllers/admin/communication/websites/posts_controller.rb
+++ b/app/controllers/admin/communication/websites/posts_controller.rb
@@ -110,7 +110,7 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We
   def post_params
     params.require(:communication_website_post)
     .permit(
-      :author_id, category_ids: [],
+      :full_width, :author_id, category_ids: [], 
       localizations_attributes: [
         :id, :title, :subtitle, :meta_description, :summary, :text,
         :published, :published_at, :slug, :pinned,
diff --git a/app/views/admin/communication/websites/posts/_form.html.erb b/app/views/admin/communication/websites/posts/_form.html.erb
index a0fd93b0a..8f7482b62 100644
--- a/app/views/admin/communication/websites/posts/_form.html.erb
+++ b/app/views/admin/communication/websites/posts/_form.html.erb
@@ -38,6 +38,7 @@
           <%= render  "admin/application/slug/form",
                       f: lf,
                       source: '#communication_website_post_localizations_attributes_0_title' %>
+          <%= f.input :full_width %>
         <% end %>
         <%= render 'admin/application/featured_image/edit', f: lf, about: @l10n %>
         <%= render 'admin/application/shared_image/edit', f: lf, about: @l10n %>
diff --git a/app/views/admin/communication/websites/posts/static.html.erb b/app/views/admin/communication/websites/posts/static.html.erb
index 66e6b02dd..0799829a2 100644
--- a/app/views/admin/communication/websites/posts/static.html.erb
+++ b/app/views/admin/communication/websites/posts/static.html.erb
@@ -4,11 +4,7 @@ language = @l10n.language
 %>---
 <%= render 'admin/application/static/core', about: @l10n %>
 <%= render 'admin/application/static/breadcrumbs', about: @l10n %>
-<%= render 'admin/application/static/design',
-            about: post,
-            l10n: @l10n,
-            full_width: false,
-            toc_offcanvas: false %>
+<%= render 'admin/application/static/design', about: post, l10n: @l10n %>
 <% if @l10n.pinned %>
 weight: 1
 <% end %>
diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml
index cf408ad41..8fc53f0a7 100644
--- a/config/locales/communication/en.yml
+++ b/config/locales/communication/en.yml
@@ -216,6 +216,7 @@ en:
       communication/website/post:
         author: Author
         categories: Categories
+        full_width: Full width
         website: Website
       communication/website/post/category:
         children: Children categories
@@ -621,4 +622,5 @@ en:
       communication_website_permalink:
         path: "Must be an URL path. Example: /old/path"
       communication_website_post:
+        full_width: On large screens, a full width post uses all available space for the content. 
         text: This field is deprecated, content will not be displayed on the website.
diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml
index 15c841616..51409105e 100644
--- a/config/locales/communication/fr.yml
+++ b/config/locales/communication/fr.yml
@@ -216,6 +216,7 @@ fr:
       communication/website/post:
         author: Auteur·rice
         categories: Catégories
+        full_width: Pleine largeur
         website: Site Web
       communication/website/post/category:
         children: Catégories enfants
@@ -621,4 +622,5 @@ fr:
       communication_website_permalink:
         path: "Doit être un chemin d'URL. Exemple : /ancien/chemin"
       communication_website_post:
+        full_width: Sur de grands écrans, l'actualité en pleine largeur utilisera tout l'espace disponible.
         text: Ce champ est déprécié, le contenu ne s'affichera pas sur le site.
diff --git a/db/migrate/20241112132644_add_full_width_to_communication_posts.rb b/db/migrate/20241112132644_add_full_width_to_communication_posts.rb
new file mode 100644
index 000000000..a267b969c
--- /dev/null
+++ b/db/migrate/20241112132644_add_full_width_to_communication_posts.rb
@@ -0,0 +1,5 @@
+class AddFullWidthToCommunicationPosts < ActiveRecord::Migration[7.2]
+  def change
+    add_column :communication_website_posts, :full_width, :boolean, default: false
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 9a265ed83..a5029f88c 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.2].define(version: 2024_10_31_101804) do
+ActiveRecord::Schema[7.2].define(version: 2024_11_12_132644) do
   # These are extensions that must be enabled in order to support this database
   enable_extension "pg_trgm"
   enable_extension "pgcrypto"
@@ -334,7 +334,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
     t.boolean "feature_jobs", default: false
     t.text "sass"
     t.text "css"
-    t.uuid "default_language_id"
+    t.uuid "default_language_id", null: false
     t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about"
     t.index ["default_language_id"], name: "index_communication_extranets_on_default_language_id"
     t.index ["university_id"], name: "index_communication_extranets_on_university_id"
@@ -550,7 +550,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
     t.boolean "header_cta"
     t.string "header_cta_label"
     t.string "header_cta_url"
-    t.string "header_text"
+    t.text "header_text"
     t.string "meta_description"
     t.string "migration_identifier"
     t.boolean "published"
@@ -749,11 +749,19 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
     t.datetime "updated_at", null: false
     t.uuid "author_id"
     t.string "migration_identifier"
+    t.boolean "full_width", default: false
     t.index ["author_id"], name: "index_communication_website_posts_on_author_id"
     t.index ["communication_website_id"], name: "index_communication_website_posts_on_communication_website_id"
     t.index ["university_id"], name: "index_communication_website_posts_on_university_id"
   end
 
+  create_table "communication_website_posts_university_persons", id: false, force: :cascade do |t|
+    t.uuid "communication_website_post_id", null: false
+    t.uuid "university_person_id", null: false
+    t.index ["communication_website_post_id", "university_person_id"], name: "post_person"
+    t.index ["university_person_id", "communication_website_post_id"], name: "person_post"
+  end
+
   create_table "communication_website_showcase_tags", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.string "name"
     t.string "slug"
@@ -1450,6 +1458,27 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
     t.index ["university_id"], name: "index_research_thesis_localizations_on_university_id"
   end
 
+  create_table "search_index", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.string "title"
+    t.text "text"
+    t.uuid "language_id", null: false
+    t.string "about_object_type", null: false
+    t.uuid "about_object_id", null: false
+    t.string "about_localization_type", null: false
+    t.uuid "about_localization_id", null: false
+    t.uuid "website_id"
+    t.uuid "extranet_id"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["about_localization_type", "about_localization_id"], name: "index_search_on_about_localization"
+    t.index ["about_object_type", "about_object_id"], name: "index_search_on_about_object"
+    t.index ["extranet_id"], name: "index_search_index_on_extranet_id"
+    t.index ["language_id"], name: "index_search_index_on_language_id"
+    t.index ["university_id"], name: "index_search_index_on_university_id"
+    t.index ["website_id"], name: "index_search_index_on_website_id"
+  end
+
   create_table "universities", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.string "name"
     t.string "identifier"
@@ -1684,7 +1713,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
   end
 
   create_table "university_person_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
-    t.string "biography"
+    t.text "biography"
     t.string "first_name"
     t.string "last_name"
     t.string "linkedin"
@@ -1977,6 +2006,9 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_31_101804) do
   add_foreign_key "research_thesis_localizations", "languages"
   add_foreign_key "research_thesis_localizations", "research_theses", column: "about_id"
   add_foreign_key "research_thesis_localizations", "universities"
+  add_foreign_key "search_index", "communication_extranets", column: "extranet_id"
+  add_foreign_key "search_index", "communication_websites", column: "website_id"
+  add_foreign_key "search_index", "universities"
   add_foreign_key "universities", "languages", column: "default_language_id"
   add_foreign_key "university_apps", "universities"
   add_foreign_key "university_organization_categories", "universities"
-- 
GitLab