1
|
|
|
class SchedulesController < ApplicationController |
2
|
|
|
def index |
3
|
|
|
unless Settings.show_schedule? || params[:force] |
4
|
|
|
redirect_to home_page_path |
5
|
|
|
return |
6
|
|
|
end |
7
|
|
|
use_cache = !params[:force] |
8
|
|
|
@event = schedule(event(use_cache)) |
9
|
|
|
render layout: 'schedule' |
10
|
|
|
end |
11
|
|
|
|
12
|
|
|
def ical |
13
|
|
|
event = Event.current_event |
14
|
|
|
|
15
|
|
|
sessions = event.sessions.includes([:room, :timeslot]) |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
cal = Icalendar::Calendar.new |
19
|
|
|
|
20
|
|
|
# Set up timezone |
21
|
|
|
cal.timezone do |
22
|
|
|
timezone_id "America/Chicago" |
23
|
|
|
|
24
|
|
|
daylight do |
25
|
|
|
timezone_offset_from "-0600" |
26
|
|
|
timezone_offset_to "-0500" |
27
|
|
|
timezone_name "CDT" |
28
|
|
|
dtstart "19700308T020000" |
29
|
|
|
add_recurrence_rule "FREQ=YEARLY;BYMONTH=3;BYDAY=2SU" |
30
|
|
|
end |
31
|
|
|
|
32
|
|
|
standard do |
33
|
|
|
timezone_offset_from "-0500" |
34
|
|
|
timezone_offset_to "-0600" |
35
|
|
|
timezone_name "CST" |
36
|
|
|
dtstart "19701101T020000" |
37
|
|
|
add_recurrence_rule "FREQ=YEARLY;BYMONTH=11;BYDAY=1SU" |
38
|
|
|
end |
39
|
|
|
end |
40
|
|
|
|
41
|
|
|
sessions.each do |session| |
42
|
|
|
next if session.timeslot.nil? |
43
|
|
|
|
44
|
|
|
cal.event do |
45
|
|
|
summary session.title |
46
|
|
|
organizer "", :CN => session.presenter_names.join("\\, ") |
47
|
|
|
description session.summary |
48
|
|
|
dtstart session.timeslot.starts_at.to_datetime |
49
|
|
|
dtend session.timeslot.ends_at.to_datetime |
50
|
|
|
|
51
|
|
|
location session.room.name |
52
|
|
|
end |
53
|
|
|
end |
54
|
|
|
|
55
|
|
|
render :text => cal.to_ical, :content_type => 'text/calendar' |
56
|
|
|
end |
57
|
|
|
|
58
|
|
|
protected |
59
|
|
|
|
60
|
|
|
def schedule(event) |
61
|
|
|
Rails.cache.fetch("#{event.cache_key}/schedule") do |
62
|
|
|
Event.includes(timeslots: { sessions: [:room, :presenters] }).find(event.id) |
63
|
|
|
end |
64
|
|
|
end |
65
|
|
|
|
66
|
|
|
# @param [TrueClass, FalseClass] cached Fetch the event from the cache? |
67
|
|
|
def event(cached) |
68
|
|
|
if cached |
69
|
|
|
Rails.cache.fetch("current_event", expires_in: 10.minutes) do |
70
|
|
|
Event.current_event |
71
|
|
|
end |
72
|
|
|
else |
73
|
|
|
Event.current_event |
74
|
|
|
end |
75
|
|
|
end |
76
|
|
|
end |
77
|
|
|
|