Skip to content
Snippets Groups Projects
Unverified Commit f5084184 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

event add_to_calendar_urls

parent 35d459ea
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
# Table name: communication_website_agenda_events
#
# id :uuid not null, primary key
# add_to_calendar_urls :jsonb
# featured_image_alt :text
# featured_image_credit :text
# from_day :date
......
module Communication::Website::Agenda::Event::WithCal
extend ActiveSupport::Concern
included do
before_save :set_add_to_calendar_urls
end
def cal
@cal ||= AddToCalendar::URLs.new(
start_datetime: cal_from_time,
......@@ -15,6 +19,16 @@ module Communication::Website::Agenda::Event::WithCal
protected
def set_add_to_calendar_urls
self.add_to_calendar_urls = {
google: cal.google_url,
yahoo: cal.yahoo_url,
office: cal.office365_url,
outlook: cal.outlook_com_url,
ical: cal.ical_url
}
end
def cal_from_time
from_hour.nil? ? from_day.to_time
: date_and_time(from_day, from_hour)
......
......@@ -26,8 +26,8 @@ indentation = ' ' * depth
<%= indentation %> hour: <%= event.to_hour.strftime "%H:%M" %>
<% end %>
<%= indentation %> add_to_calendar:
<%= indentation %> google: "<%= event.cal.google_url.html_safe %>"
<%= indentation %> yahoo: "<%= event.cal.yahoo_url.html_safe %>"
<%= indentation %> office: "<%= event.cal.office365_url.html_safe %>"
<%= indentation %> outlook: "<%= event.cal.outlook_com_url.html_safe %>"
<%= indentation %> ical: "<%= event.cal.ical_url.html_safe %>"
<%= indentation %> google: "<%= event.add_to_calendar_urls['google'].html_safe %>"
<%= indentation %> yahoo: "<%= event.add_to_calendar_urls['yahoo'].html_safe %>"
<%= indentation %> office: "<%= event.add_to_calendar_urls['office'].html_safe %>"
<%= indentation %> outlook: "<%= event.add_to_calendar_urls['outlook'].html_safe %>"
<%= indentation %> ical: "<%= event.add_to_calendar_urls['ical'].html_safe %>"
class AddAddToCalendarUrlsToCommunicationWebsiteAgendaEvents < ActiveRecord::Migration[7.1]
def change
add_column :communication_website_agenda_events, :add_to_calendar_urls, :jsonb
Communication::Website::Agenda::Event.reset_column_information
Communication::Website::Agenda::Event.find_each(&:save)
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_02_07_085338) do
ActiveRecord::Schema[7.1].define(version: 2024_02_08_131753) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
......@@ -311,6 +311,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_07_085338) do
t.string "slug"
t.string "subtitle"
t.string "time_zone"
t.jsonb "add_to_calendar_urls"
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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment