From 79ed66c096bc3b0c4d81bd25fd8dc4f0e46247d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Mon, 16 May 2022 10:22:41 +0200
Subject: [PATCH] #385 : header_text

---
 app/views/admin/communication/websites/pages/_form.html.erb | 6 +-----
 .../admin/communication/websites/pages/static.html.erb      | 4 ++--
 lib/tasks/app.rake                                          | 5 +++++
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb
index d334eca97..f2c2e2064 100644
--- a/app/views/admin/communication/websites/pages/_form.html.erb
+++ b/app/views/admin/communication/websites/pages/_form.html.erb
@@ -12,11 +12,7 @@
           <%= f.input :title %>
           <%= f.input :breadcrumb_title %>
           <%= f.input :description_short, input_html: { value: page.description_short&.gsub('&amp;', '&') } %>
-          <%= f.input :header_text,
-                      as: :summernote,
-                      input_html: {
-                        data: { 'summernote-config' => 'mini' }
-                      } %>
+          <%= 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),
diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb
index c3f1d35ee..710adbec9 100644
--- a/app/views/admin/communication/websites/pages/static.html.erb
+++ b/app/views/admin/communication/websites/pages/static.html.erb
@@ -19,8 +19,8 @@ description: >
   <%= prepare_text_for_static @about.description %>
 description_short: >
   <%= prepare_text_for_static @about.description_short %>
-header_text: >
-  <%= prepare_html_for_static @about.header_text, @website.university %>
+header_text: >-
+  <%= @about.header_text %>
 legacy_text: >
   <%= prepare_html_for_static @about.text, @about.university %>
 <%= render 'admin/communication/blocks/static', about: @about %>
diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake
index c83caba11..d8cb814a9 100644
--- a/lib/tasks/app.rake
+++ b/lib/tasks/app.rake
@@ -12,6 +12,11 @@ namespace :app do
       person.is_author = person.communication_website_posts.any?
       person.save
     end
+
+    Communication::Website::Page.where("header_text ILIKE ?", "%<p>%").find_each { |page|
+      clean_header_text = ActionController::Base.helpers.strip_tags(page.header_text)
+      page.update(header_text: clean_header_text)
+    }
   end
 
   namespace :websites do
-- 
GitLab