From e887daee60381b8f72d9455227f9aaf8c4766e4e Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 31 Oct 2023 11:50:34 +0100
Subject: [PATCH] =?UTF-8?q?Sous-titres=20des=20=C3=A9v=C3=A9nements?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../communication/websites/agenda/events_controller.rb |  2 +-
 app/models/communication/website/agenda/event.rb       |  1 +
 .../websites/agenda/events/_form.html.erb              |  1 +
 .../communication/websites/agenda/events/show.html.erb |  3 +++
 ..._subtitle_to_communication_website_agenda_events.rb |  5 +++++
 db/schema.rb                                           | 10 +++++++++-
 test/fixtures/communication/website/agenda/events.yml  |  1 +
 test/models/communication/website/agenda/event_test.rb |  1 +
 8 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 db/migrate/20231031104523_add_subtitle_to_communication_website_agenda_events.rb

diff --git a/app/controllers/admin/communication/websites/agenda/events_controller.rb b/app/controllers/admin/communication/websites/agenda/events_controller.rb
index a78ff1a91..a5816f196 100644
--- a/app/controllers/admin/communication/websites/agenda/events_controller.rb
+++ b/app/controllers/admin/communication/websites/agenda/events_controller.rb
@@ -78,7 +78,7 @@ class Admin::Communication::Websites::Agenda::EventsController < Admin::Communic
   def event_params
     params.require(:communication_website_agenda_event)
     .permit(
-      :title, :meta_description, :summary, :published, :slug,
+      :title, :subtitle, :meta_description, :summary, :published, :slug,
       :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit,
       :from_day, :from_hour, :to_day, :to_hour
     )
diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb
index 67c710dae..506d611c9 100644
--- a/app/models/communication/website/agenda/event.rb
+++ b/app/models/communication/website/agenda/event.rb
@@ -10,6 +10,7 @@
 #  meta_description         :text
 #  published                :boolean          default(FALSE)
 #  slug                     :string           indexed
+#  subtitle                 :string
 #  summary                  :text
 #  title                    :string
 #  to_day                   :date
diff --git a/app/views/admin/communication/websites/agenda/events/_form.html.erb b/app/views/admin/communication/websites/agenda/events/_form.html.erb
index 576ba9c86..9499024d1 100644
--- a/app/views/admin/communication/websites/agenda/events/_form.html.erb
+++ b/app/views/admin/communication/websites/agenda/events/_form.html.erb
@@ -6,6 +6,7 @@
     <div class="col-md-8">
       <%= osuny_panel t('content') do %>
         <%= f.input :title %>
+        <%= f.input :subtitle %>
         <%= render 'admin/application/summary/form', f: f, about: event %>
       <% end %>
       <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name('dates') do %>
diff --git a/app/views/admin/communication/websites/agenda/events/show.html.erb b/app/views/admin/communication/websites/agenda/events/show.html.erb
index 3bd2fded9..52f8cfeda 100644
--- a/app/views/admin/communication/websites/agenda/events/show.html.erb
+++ b/app/views/admin/communication/websites/agenda/events/show.html.erb
@@ -5,6 +5,9 @@
     <div class="col-lg-7">
       <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name(:title), small: true do %>
         <p class="lead"><%= @event.title %></p>
+        <% if @event.subtitle.present? %>
+          <p class="mt-n3 text-muted"><%= @event.subtitle %></p>
+        <% end %>
         <p><%= render 'admin/communication/websites/agenda/events/dates', event: @event %></p>
       <% end %>
     </div>
diff --git a/db/migrate/20231031104523_add_subtitle_to_communication_website_agenda_events.rb b/db/migrate/20231031104523_add_subtitle_to_communication_website_agenda_events.rb
new file mode 100644
index 000000000..4e9e639bb
--- /dev/null
+++ b/db/migrate/20231031104523_add_subtitle_to_communication_website_agenda_events.rb
@@ -0,0 +1,5 @@
+class AddSubtitleToCommunicationWebsiteAgendaEvents < ActiveRecord::Migration[7.1]
+  def change
+    add_column :communication_website_agenda_events, :subtitle, :string
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 659e0ae39..f51e03655 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.1].define(version: 2023_10_18_182341) do
+ActiveRecord::Schema[7.1].define(version: 2023_10_31_104523) do
   # These are extensions that must be enabled in order to support this database
   enable_extension "pgcrypto"
   enable_extension "plpgsql"
@@ -252,6 +252,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_18_182341) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.string "slug"
+    t.string "subtitle"
     t.index ["communication_website_id"], name: "index_agenda_events_on_communication_website_id"
     t.index ["language_id"], name: "index_communication_website_agenda_events_on_language_id"
     t.index ["original_id"], name: "index_communication_website_agenda_events_on_original_id"
@@ -260,6 +261,13 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_18_182341) do
     t.index ["university_id"], name: "index_communication_website_agenda_events_on_university_id"
   end
 
+  create_table "communication_website_agenda_events_categories", id: false, force: :cascade do |t|
+    t.uuid "communication_website_agenda_event_id", null: false
+    t.uuid "communication_website_category_id", null: false
+    t.index ["communication_website_agenda_event_id", "communication_website_category_id"], name: "event_category"
+    t.index ["communication_website_category_id", "communication_website_agenda_event_id"], name: "category_event"
+  end
+
   create_table "communication_website_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "communication_website_id", null: false
diff --git a/test/fixtures/communication/website/agenda/events.yml b/test/fixtures/communication/website/agenda/events.yml
index d813866e4..01f5d18da 100644
--- a/test/fixtures/communication/website/agenda/events.yml
+++ b/test/fixtures/communication/website/agenda/events.yml
@@ -10,6 +10,7 @@
 #  meta_description         :text
 #  published                :boolean          default(FALSE)
 #  slug                     :string           indexed
+#  subtitle                 :string
 #  summary                  :text
 #  title                    :string
 #  to_day                   :date
diff --git a/test/models/communication/website/agenda/event_test.rb b/test/models/communication/website/agenda/event_test.rb
index c8ca3e172..17615a6e9 100644
--- a/test/models/communication/website/agenda/event_test.rb
+++ b/test/models/communication/website/agenda/event_test.rb
@@ -10,6 +10,7 @@
 #  meta_description         :text
 #  published                :boolean          default(FALSE)
 #  slug                     :string           indexed
+#  subtitle                 :string
 #  summary                  :text
 #  title                    :string
 #  to_day                   :date
-- 
GitLab