mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add icalendar files (fixes #2147)
This commit is contained in:
parent
32164c47db
commit
d540092bfc
6 changed files with 80 additions and 0 deletions
|
|
@ -67,6 +67,45 @@ class ConferencesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def calendar
|
||||
respond_to do |format|
|
||||
format.ics do
|
||||
calendar = Icalendar::Calendar.new
|
||||
Conference.all.each do |conf|
|
||||
if params[:full]
|
||||
event_schedules = conf.program.selected_event_schedules(
|
||||
includes: [{ event: %i[event_type speakers submitter] }]
|
||||
)
|
||||
calendar = icalendar_proposals(calendar, event_schedules.map(&:event), conf)
|
||||
else
|
||||
calendar.event do |e|
|
||||
e.dtstart = conf.start_date
|
||||
e.dtstart.ical_params = { 'VALUE'=>'DATE' }
|
||||
e.dtend = conf.end_date
|
||||
e.dtend.ical_params = { 'VALUE'=>'DATE' }
|
||||
e.duration = "P#{(conf.end_date - conf.start_date + 1).floor}D"
|
||||
e.created = conf.created_at
|
||||
e.last_modified = conf.updated_at
|
||||
e.summary = conf.title
|
||||
e.description = conf.description
|
||||
e.uid = conf.guid
|
||||
e.url = conference_url(conf.short_title)
|
||||
v = conf.venue
|
||||
e.geo = v.latitude, v.longitude if v.latitude && v.longitude
|
||||
location = ''
|
||||
location += "#{v.street}, " if v.street
|
||||
location += "#{v.postalcode} #{v.city}, " if v.postalcode && v.city
|
||||
location += v.country_name if v.country_name
|
||||
e.location = location if location
|
||||
end
|
||||
end
|
||||
end
|
||||
calendar.publish
|
||||
render inline: calendar.to_ical
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def conference_finder_conditions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue