2014-05-19 21:21:06 +05:30
class ConferenceController < ApplicationController
2016-03-09 14:12:31 +01:00
protect_from_forgery with : :null_session
2014-11-14 17:24:24 +01:00
before_filter :respond_to_options
2014-08-12 11:51:59 +03:00
load_and_authorize_resource find_by : :short_title
2015-10-25 13:29:02 +02:00
load_resource :program , through : :conference , singleton : true , except : :index
2014-08-12 11:51:59 +03:00
2014-11-14 17:24:24 +01:00
def index
2016-06-23 12:24:58 +03:00
@current = Conference . where ( 'end_date >= ?' , Date . current ) . reorder ( start_date : :asc )
2014-11-14 17:24:24 +01:00
@antiquated = @conferences - @current
end
2014-12-08 18:08:21 +02:00
def show ; end
2014-06-30 19:24:26 +05:30
2014-11-27 14:31:44 +01:00
def schedule
2015-11-07 11:43:36 +02:00
@rooms = @conference . venue . rooms if @conference . venue
2016-07-20 23:20:47 +02:00
unless @program . selected_schedule . present? && @program . events . scheduled ( @program . selected_schedule ) . any?
2016-06-30 16:53:15 +02:00
redirect_to events_conference_path ( @conference . short_title )
end
2015-10-25 13:29:02 +02:00
@events = @conference . program . events
2016-07-20 23:20:47 +02:00
@events_xml = @program . schedules . find ( program . selected_schedule ) . event_schedules . where ( 'start_time IS NOT NULL AND room_id IS NOT NULL' ) . order ( start_time : :asc )
. map ( & :event ) . group_by { | event | event . scheduled_start_time . to_date } if program . selected_schedule . present?
2014-11-27 14:31:44 +01:00
@dates = @conference . start_date .. @conference . end_date
2016-06-13 13:34:55 +02:00
@step_minutes = EventType :: LENGTH_STEP . minutes
2016-06-10 16:33:57 +02:00
@conf_start = 9
conf_end = 20
2016-06-13 13:34:55 +02:00
@conf_period = conf_end - @conf_start
2016-07-02 17:23:56 +02:00
# the schedule takes you to today if it is a date of the schedule
@current_day = @conference . current_conference_day
@day = @current_day . present? ? @current_day : @dates . first
return unless @current_day
# the schedule takes you to the current time if it is beetween the start and the end time.
@hour_column = @conference . hours_from_start_time ( @conf_start , conf_end )
2016-06-30 16:53:15 +02:00
end
def events
@dates = @conference . start_date .. @conference . end_date
2016-06-10 16:33:57 +02:00
2016-07-20 23:20:47 +02:00
if @program . selected_schedule . present?
@events_schedules = @program . schedules . find ( @program . selected_schedule ) . event_schedules . where ( 'start_time IS NOT NULL AND room_id IS NOT NULL' ) . order ( start_time : :asc )
else
@events_schedules = [ ]
end
@unscheduled_events = @program . events . unscheduled ( @program . selected_schedule . id )
2016-07-01 11:41:16 +02:00
day = @conference . current_conference_day
@tag = day . strftime ( '%Y-%m-%d' ) if day
2014-11-27 14:31:44 +01:00
end
2014-11-14 17:24:24 +01:00
private
2015-10-28 18:05:15 +02:00
def respond_to_options
respond_to do | format |
format . html { head :ok }
end if request . options?
end
2014-05-19 21:21:06 +05:30
end