From ed88bc25701f9a10ec4ec5749c1219a448203f32 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <arnaud.levy@noesya.coop>
Date: Mon, 3 Mar 2025 12:16:16 +0100
Subject: [PATCH] Blocs dans le footer (#2734)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Footer blocks

* dependencies + a11y

* text

---------

Co-authored-by: Sébastien Gaya <sebastien.gaya@gmail.com>
---
 .../communication/website/localization.rb     |   9 +-
 .../websites/edit_language.html.erb           |   7 +-
 .../communication/websites/static.html.erb    |   1 +
 config/locales/communication/contents/en.yml  |   1 +
 config/locales/communication/contents/fr.yml  |   1 +
 db/schema.rb                                  | 110 ++++++++++++++++++
 6 files changed, 127 insertions(+), 2 deletions(-)

diff --git a/app/models/communication/website/localization.rb b/app/models/communication/website/localization.rb
index 60a4013d3..bf72243c4 100644
--- a/app/models/communication/website/localization.rb
+++ b/app/models/communication/website/localization.rb
@@ -37,7 +37,9 @@
 #
 class Communication::Website::Localization < ApplicationRecord
   include AsLocalization
+  include Contentful
   include Initials
+  include WithAccessibility
   include WithOpenApi
   include WithPublication
   include WithUniversity
@@ -58,7 +60,8 @@ class Communication::Website::Localization < ApplicationRecord
 
   def dependencies
     # 1 single file for all the languages
-    [website.config_default_languages]
+    [website.config_default_languages] +
+    contents_dependencies
   end
 
   def to_s
@@ -67,6 +70,10 @@ class Communication::Website::Localization < ApplicationRecord
 
   protected
 
+  def check_accessibility
+    accessibility_merge_array blocks
+  end
+
   def create_existing_menus_in_language
     menus = website.menus.for_language_id(website.default_language_id)
     menus.each do |menu|
diff --git a/app/views/admin/communication/websites/edit_language.html.erb b/app/views/admin/communication/websites/edit_language.html.erb
index 1e2e203ca..3737a0e7a 100644
--- a/app/views/admin/communication/websites/edit_language.html.erb
+++ b/app/views/admin/communication/websites/edit_language.html.erb
@@ -18,10 +18,15 @@
       </div>
       <div class="col-lg-8">
         <%= render 'admin/application/contact_details/edit', f: f, lf: lf, about: @website, l10n: @l10n %>
+        <%= osuny_separator %>
       </div>
-      <div class="col-lg-6 col-xxl-4">
+    </div>
+    <div class="row">
+      <div class="offset-lg-4 col-lg-8 col-xxl-6">
+        <p><%= t('admin.communication.blocks.footer') %></p>
       </div>
     </div>
+    <%= render 'admin/communication/contents/editor', about: @l10n %>
 
     <% content_for :action_bar_right do %>
       <%= submit f %>
diff --git a/app/views/admin/communication/websites/static.html.erb b/app/views/admin/communication/websites/static.html.erb
index 5cabf7e62..3339b4ac3 100644
--- a/app/views/admin/communication/websites/static.html.erb
+++ b/app/views/admin/communication/websites/static.html.erb
@@ -7,3 +7,4 @@ default:
   shared_image:
     id: <%= @website.default_shared_image.blob&.id %>
 <% end %>
+<%= render 'admin/communication/contents/static', about: @l10n %>
diff --git a/config/locales/communication/contents/en.yml b/config/locales/communication/contents/en.yml
index 9098a42c9..4034c07d1 100644
--- a/config/locales/communication/contents/en.yml
+++ b/config/locales/communication/contents/en.yml
@@ -67,6 +67,7 @@ en:
             close: Close block edition
             title: Block edition
         empty: This block is empty and will not appear
+        footer: The blocks here appear in the website footer, on each page.
         templates:
           agenda:
             description: A list of upcoming events.
diff --git a/config/locales/communication/contents/fr.yml b/config/locales/communication/contents/fr.yml
index 447a11bd1..73ddd9a8c 100644
--- a/config/locales/communication/contents/fr.yml
+++ b/config/locales/communication/contents/fr.yml
@@ -67,6 +67,7 @@ fr:
             close: Fermer l'édition du bloc
             title: Édition de bloc
         empty: Ce bloc est vide et n'apparaitra pas
+        footer: Les blocs ajoutés ici apparaissent dans le pied de page (footer) du site, sur chaque page.
         templates:
           agenda:
             description: Une liste d'événements à venir.
diff --git a/db/schema.rb b/db/schema.rb
index 63ea4c722..066eb427f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -486,6 +486,13 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_24_215711) do
     t.index ["event_id", "category_id"], name: "event_category"
   end
 
+  create_table "communication_website_agenda_categories_exhibitions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "category_id", null: false
+    t.uuid "exhibition_id", null: false
+    t.index ["category_id"], name: "idx_on_category_id_8612661ce8"
+    t.index ["exhibition_id"], name: "idx_on_exhibition_id_462c88c523"
+  end
+
   create_table "communication_website_agenda_category_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.string "featured_image_alt"
     t.text "featured_image_credit"
@@ -507,6 +514,20 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_24_215711) do
     t.index ["university_id"], name: "idx_on_university_id_934ff72e5e"
   end
 
+  create_table "communication_website_agenda_event_days", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "language_id", null: false
+    t.uuid "communication_website_id", null: false
+    t.uuid "communication_website_agenda_event_id", null: false
+    t.date "date"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["communication_website_agenda_event_id"], name: "idx_on_communication_website_agenda_event_id_4defccd002"
+    t.index ["communication_website_id"], name: "idx_on_communication_website_id_38a3895ffa"
+    t.index ["language_id"], name: "index_communication_website_agenda_event_days_on_language_id"
+    t.index ["university_id"], name: "index_communication_website_agenda_event_days_on_university_id"
+  end
+
   create_table "communication_website_agenda_event_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.jsonb "add_to_calendar_urls"
     t.string "featured_image_alt"
@@ -535,6 +556,34 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_24_215711) do
     t.index ["university_id"], name: "idx_on_university_id_eaf79b0514"
   end
 
+  create_table "communication_website_agenda_event_time_slot_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "communication_website_id", null: false
+    t.uuid "about_id", null: false
+    t.uuid "language_id", null: false
+    t.string "place"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.jsonb "add_to_calendar_urls"
+    t.index ["about_id"], name: "idx_on_about_id_e52a2e12b0"
+    t.index ["communication_website_id"], name: "idx_on_communication_website_id_526f156fed"
+    t.index ["language_id"], name: "idx_on_language_id_f50f565794"
+    t.index ["university_id"], name: "idx_on_university_id_4dee92bcc5"
+  end
+
+  create_table "communication_website_agenda_event_time_slots", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "communication_website_id", null: false
+    t.uuid "communication_website_agenda_event_id", null: false
+    t.datetime "datetime"
+    t.integer "duration"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["communication_website_agenda_event_id"], name: "idx_on_communication_website_agenda_event_id_022d825cf7"
+    t.index ["communication_website_id"], name: "idx_on_communication_website_id_c0ac516bb5"
+    t.index ["university_id"], name: "idx_on_university_id_bca328e63c"
+  end
+
   create_table "communication_website_agenda_events", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "communication_website_id", null: false
@@ -554,6 +603,48 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_24_215711) do
     t.index ["university_id"], name: "index_communication_website_agenda_events_on_university_id"
   end
 
+  create_table "communication_website_agenda_exhibition_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.jsonb "add_to_calendar_urls"
+    t.string "featured_image_alt"
+    t.text "featured_image_credit"
+    t.boolean "header_cta"
+    t.string "header_cta_label"
+    t.string "header_cta_url"
+    t.string "meta_description"
+    t.string "migration_identifier"
+    t.boolean "published", default: false
+    t.datetime "published_at"
+    t.string "slug"
+    t.string "subtitle"
+    t.text "summary"
+    t.string "title"
+    t.uuid "about_id", null: false
+    t.uuid "language_id", null: false
+    t.uuid "university_id", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.uuid "communication_website_id", null: false
+    t.index ["about_id"], name: "idx_on_about_id_a6e772a338"
+    t.index ["communication_website_id"], name: "idx_on_communication_website_id_8261badeaa"
+    t.index ["language_id"], name: "idx_on_language_id_a2de6ce8d0"
+    t.index ["university_id"], name: "idx_on_university_id_64ba331f7d"
+  end
+
+  create_table "communication_website_agenda_exhibitions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "communication_website_id", null: false
+    t.uuid "created_by_id"
+    t.date "from_day"
+    t.date "to_day"
+    t.string "migration_identifier"
+    t.string "time_zone"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["communication_website_id"], name: "index_agenda_exhibitions_on_communication_website_id"
+    t.index ["created_by_id"], name: "idx_on_created_by_id_c3766f3a0a"
+    t.index ["university_id"], name: "idx_on_university_id_46e895f493"
+  end
+
   create_table "communication_website_connections", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "website_id", null: false
@@ -2070,18 +2161,37 @@ ActiveRecord::Schema[7.2].define(version: 2025_02_24_215711) do
   add_foreign_key "communication_website_agenda_categories", "communication_websites"
   add_foreign_key "communication_website_agenda_categories", "education_programs", column: "program_id"
   add_foreign_key "communication_website_agenda_categories", "universities"
+  add_foreign_key "communication_website_agenda_categories_exhibitions", "communication_website_agenda_categories", column: "category_id"
+  add_foreign_key "communication_website_agenda_categories_exhibitions", "communication_website_agenda_exhibitions", column: "exhibition_id"
   add_foreign_key "communication_website_agenda_category_localizations", "communication_website_agenda_categories", column: "about_id"
   add_foreign_key "communication_website_agenda_category_localizations", "communication_websites"
   add_foreign_key "communication_website_agenda_category_localizations", "languages"
   add_foreign_key "communication_website_agenda_category_localizations", "universities"
+  add_foreign_key "communication_website_agenda_event_days", "communication_website_agenda_events"
+  add_foreign_key "communication_website_agenda_event_days", "communication_websites"
+  add_foreign_key "communication_website_agenda_event_days", "languages"
+  add_foreign_key "communication_website_agenda_event_days", "universities"
   add_foreign_key "communication_website_agenda_event_localizations", "communication_website_agenda_events", column: "about_id"
   add_foreign_key "communication_website_agenda_event_localizations", "communication_websites"
   add_foreign_key "communication_website_agenda_event_localizations", "languages"
   add_foreign_key "communication_website_agenda_event_localizations", "universities"
+  add_foreign_key "communication_website_agenda_event_time_slot_localizations", "communication_website_agenda_event_time_slots", column: "about_id"
+  add_foreign_key "communication_website_agenda_event_time_slot_localizations", "communication_websites"
+  add_foreign_key "communication_website_agenda_event_time_slot_localizations", "languages"
+  add_foreign_key "communication_website_agenda_event_time_slot_localizations", "universities"
+  add_foreign_key "communication_website_agenda_event_time_slots", "communication_website_agenda_events"
+  add_foreign_key "communication_website_agenda_event_time_slots", "communication_websites"
+  add_foreign_key "communication_website_agenda_event_time_slots", "universities"
   add_foreign_key "communication_website_agenda_events", "communication_website_agenda_events", column: "parent_id"
   add_foreign_key "communication_website_agenda_events", "communication_websites"
   add_foreign_key "communication_website_agenda_events", "universities"
   add_foreign_key "communication_website_agenda_events", "users", column: "created_by_id"
+  add_foreign_key "communication_website_agenda_exhibition_localizations", "communication_website_agenda_exhibitions", column: "about_id"
+  add_foreign_key "communication_website_agenda_exhibition_localizations", "communication_websites"
+  add_foreign_key "communication_website_agenda_exhibition_localizations", "universities"
+  add_foreign_key "communication_website_agenda_exhibitions", "communication_websites"
+  add_foreign_key "communication_website_agenda_exhibitions", "universities"
+  add_foreign_key "communication_website_agenda_exhibitions", "users", column: "created_by_id"
   add_foreign_key "communication_website_connections", "communication_websites", column: "website_id"
   add_foreign_key "communication_website_connections", "universities"
   add_foreign_key "communication_website_git_file_layouts", "communication_websites"
-- 
GitLab