|
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
|
|
|
@event = Event.current_event |
|
8
|
|
|
render layout: 'schedule' |
|
9
|
|
|
end |
|
10
|
|
|
|
|
11
|
|
|
def ical |
|
12
|
|
|
event = Event.current_event |
|
13
|
|
|
|
|
14
|
|
|
sessions = event.sessions.includes([:room, :timeslot]) |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
cal = Icalendar::Calendar.new |
|
18
|
|
|
|
|
19
|
|
|
# Set up timezone |
|
20
|
|
|
cal.timezone do |
|
21
|
|
|
timezone_id "America/Chicago" |
|
22
|
|
|
|
|
23
|
|
|
daylight do |
|
24
|
|
|
timezone_offset_from "-0600" |
|
25
|
|
|
timezone_offset_to "-0500" |
|
26
|
|
|
timezone_name "CDT" |
|
27
|
|
|
dtstart "19700308T020000" |
|
28
|
|
|
add_recurrence_rule "FREQ=YEARLY;BYMONTH=3;BYDAY=2SU" |
|
29
|
|
|
end |
|
30
|
|
|
|
|
31
|
|
|
standard do |
|
32
|
|
|
timezone_offset_from "-0500" |
|
33
|
|
|
timezone_offset_to "-0600" |
|
34
|
|
|
timezone_name "CST" |
|
35
|
|
|
dtstart "19701101T020000" |
|
36
|
|
|
add_recurrence_rule "FREQ=YEARLY;BYMONTH=11;BYDAY=1SU" |
|
37
|
|
|
end |
|
38
|
|
|
end |
|
39
|
|
|
|
|
40
|
|
|
sessions.each do |session| |
|
41
|
|
|
next if session.timeslot.nil? |
|
42
|
|
|
|
|
43
|
|
|
cal.event do |
|
44
|
|
|
summary session.title |
|
45
|
|
|
organizer "", :CN => session.presenter_names.join("\\, ") |
|
46
|
|
|
description session.summary |
|
47
|
|
|
dtstart session.timeslot.starts_at.to_datetime |
|
48
|
|
|
dtend session.timeslot.ends_at.to_datetime |
|
49
|
|
|
|
|
50
|
|
|
location session.room.name |
|
51
|
|
|
end |
|
52
|
|
|
end |
|
53
|
|
|
|
|
54
|
|
|
render plain: cal.to_ical, :content_type => 'text/calendar' |
|
55
|
|
|
end |
|
56
|
|
|
|
|
57
|
|
|
def event_timeslots |
|
58
|
|
|
@event_timeslots ||= load_event.timeslots |
|
59
|
|
|
end |
|
60
|
|
|
helper_method :event_timeslots |
|
61
|
|
|
|
|
62
|
|
|
private |
|
63
|
|
|
|
|
64
|
|
|
def load_event |
|
65
|
|
|
event = Event.includes(timeslots: { sessions: [:room, :presenters] }).find(Event.current_event.id) |
|
66
|
|
|
|
|
67
|
|
|
# Preload vote counts in order to sort sessions by popularity |
|
68
|
|
|
Session.preload_attendance_counts( |
|
69
|
|
|
event.timeslots.map(&:sessions).flatten) |
|
70
|
|
|
|
|
71
|
|
|
event |
|
72
|
|
|
end |
|
73
|
|
|
|
|
74
|
|
|
end |
|
75
|
|
|
|