SchedulesController introduced
The actions #schedule and #events were moved from conference controller to the new controller
This commit is contained in:
parent
b037a5eb7c
commit
71dab6b79c
18 changed files with 87 additions and 69 deletions
|
|
@ -11,41 +11,6 @@ class ConferenceController < ApplicationController
|
||||||
|
|
||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def schedule
|
|
||||||
@rooms = @conference.venue.rooms if @conference.venue
|
|
||||||
unless @program.selected_schedule.present? && @program.events.scheduled(@program.selected_schedule.id).any?
|
|
||||||
redirect_to events_conference_path(@conference.short_title)
|
|
||||||
end
|
|
||||||
|
|
||||||
@events = @conference.program.events
|
|
||||||
schedules = @program.selected_event_schedules
|
|
||||||
@events_xml = schedules.map(&:event).group_by{ |event| event.scheduled_start_time.to_date } if schedules
|
|
||||||
@dates = @conference.start_date..@conference.end_date
|
|
||||||
@step_minutes = EventType::LENGTH_STEP.minutes
|
|
||||||
@conf_start = 9
|
|
||||||
conf_end = 20
|
|
||||||
@conf_period = conf_end - @conf_start
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
end
|
|
||||||
|
|
||||||
def events
|
|
||||||
@dates = @conference.start_date..@conference.end_date
|
|
||||||
|
|
||||||
@events_schedules = @program.selected_event_schedules
|
|
||||||
@events_schedules = [] unless @events_schedules
|
|
||||||
|
|
||||||
@unscheduled_events = @program.events.unscheduled(@program.selected_schedule.id)
|
|
||||||
|
|
||||||
day = @conference.current_conference_day
|
|
||||||
@tag = day.strftime('%Y-%m-%d') if day
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def respond_to_options
|
def respond_to_options
|
||||||
|
|
|
||||||
48
app/controllers/schedules_controller.rb
Normal file
48
app/controllers/schedules_controller.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
class SchedulesController < ApplicationController
|
||||||
|
protect_from_forgery with: :null_session
|
||||||
|
before_action :respond_to_options
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_resource :program, through: :conference, singleton: true, except: :index
|
||||||
|
|
||||||
|
def show
|
||||||
|
@rooms = @conference.venue.rooms if @conference.venue
|
||||||
|
unless @program.selected_schedule.present? && @program.events.scheduled(@program.selected_schedule.id).any?
|
||||||
|
redirect_to events_conference_schedule_path(@conference.short_title)
|
||||||
|
end
|
||||||
|
|
||||||
|
schedules = @program.selected_event_schedules
|
||||||
|
@events_xml = schedules.map(&:event).group_by{ |event| event.scheduled_start_time.to_date } if schedules
|
||||||
|
@dates = @conference.start_date..@conference.end_date
|
||||||
|
@step_minutes = EventType::LENGTH_STEP.minutes
|
||||||
|
@conf_start = 9
|
||||||
|
conf_end = 20
|
||||||
|
@conf_period = conf_end - @conf_start
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
end
|
||||||
|
|
||||||
|
def events
|
||||||
|
@dates = @conference.start_date..@conference.end_date
|
||||||
|
|
||||||
|
@events_schedules = @program.selected_event_schedules
|
||||||
|
@events_schedules = [] unless @events_schedules
|
||||||
|
|
||||||
|
@unscheduled_events = @program.events.unscheduled(@program.selected_schedule.id)
|
||||||
|
|
||||||
|
day = @conference.current_conference_day
|
||||||
|
@tag = day.strftime('%Y-%m-%d') if day
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def respond_to_options
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { head :ok }
|
||||||
|
end if request.options?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -13,7 +13,7 @@ class EmailSettings < ActiveRecord::Base
|
||||||
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
||||||
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
||||||
|
|
||||||
'schedule_link' => Rails.application.routes.url_helpers.schedule_conference_url(
|
'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url(
|
||||||
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
|
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
%h1 Commercials
|
%h1 Commercials
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
Conference commercials will be displayed on the events in the
|
Conference commercials will be displayed on the events in the
|
||||||
= link_to "schedule,", schedule_conference_path(@conference.short_title)
|
= link_to "schedule,", conference_schedule_path(@conference.short_title)
|
||||||
if the event speaker didn't add an event commercial.
|
if the event speaker didn't add an event commercial.
|
||||||
- if can? :create, @conference.commercials.new
|
- if can? :create, @conference.commercials.new
|
||||||
.row
|
.row
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
- if conference.splashpage && conference.splashpage.public
|
- if conference.splashpage && conference.splashpage.public
|
||||||
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- if conference.program and conference.program.schedule_public
|
- if conference.program and conference.program.schedule_public
|
||||||
= link_to "Schedule", schedule_conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- if conference.registration_open?
|
- if conference.registration_open?
|
||||||
- if conference.user_registered?(current_user)
|
- if conference.user_registered?(current_user)
|
||||||
= link_to "My Registration", conference_conference_registration_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "My Registration", conference_conference_registration_path(conference.short_title), :class =>"btn btn-default"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%p.cta-button.text-center
|
%p.cta-button.text-center
|
||||||
= link_to(schedule_conference_path(@conference.short_title), class: 'btn btn-default btn-lg') do
|
= link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do
|
||||||
Full Schedule
|
Full Schedule
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
- if can? :edit, @event
|
- if can? :edit, @event
|
||||||
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary"
|
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary"
|
||||||
- if can? :schedule, @conference
|
- if can? :schedule, @conference
|
||||||
= link_to "Schedule", schedule_conference_path(@conference.short_title), :class =>"btn btn-success"
|
= link_to "Schedule", conference_schedule_path(@conference.short_title), :class =>"btn btn-success"
|
||||||
|
|
||||||
- if @event.state == 'canceled' || @event.state == 'withdrawn'
|
- if @event.state == 'canceled' || @event.state == 'withdrawn'
|
||||||
%span.label.label-danger CANCELED
|
%span.label.label-danger CANCELED
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
/ Nav tabs
|
/ Nav tabs
|
||||||
%ul.nav.nav-tabs{ role: "tablist" }
|
%ul.nav.nav-tabs{ role: "tablist" }
|
||||||
%li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" }
|
%li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" }
|
||||||
= link_to('Schedule', schedule_conference_path(@conference.short_title))
|
= link_to('Schedule', conference_schedule_path(@conference.short_title))
|
||||||
%li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" }
|
%li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" }
|
||||||
= link_to('All events', events_conference_path(@conference.short_title))
|
= link_to('All events', events_conference_schedule_path(@conference.short_title))
|
||||||
|
|
@ -112,10 +112,10 @@ Osem::Application.routes.draw do
|
||||||
resources :tickets, only: [:index]
|
resources :tickets, only: [:index]
|
||||||
resources :ticket_purchases, only: [:create, :destroy]
|
resources :ticket_purchases, only: [:create, :destroy]
|
||||||
resource :subscriptions, only: [:create, :destroy]
|
resource :subscriptions, only: [:create, :destroy]
|
||||||
|
resource :schedule, only: [:show] do
|
||||||
member do
|
member do
|
||||||
get :schedule
|
get :events
|
||||||
get :events
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,29 +26,6 @@ describe ConferenceController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #schedule' do
|
|
||||||
context 'XML' do
|
|
||||||
before :each do
|
|
||||||
conference.program.schedule_public = true
|
|
||||||
conference.program.save!
|
|
||||||
create(:event_scheduled, program: conference.program)
|
|
||||||
create(:event_scheduled, program: conference.program)
|
|
||||||
|
|
||||||
get :schedule, id: conference.short_title, format: :xml
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'assigns variables' do
|
|
||||||
expect(assigns(:conference)).to eq conference
|
|
||||||
expect(assigns(:events_xml)).to eq conference.selected_event_schedules.map(&:event)
|
|
||||||
.group_by{ |event| event.scheduled_start_time.to_date }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders successfully' do
|
|
||||||
expect(response).to be_success
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'OPTIONS #index' do
|
describe 'OPTIONS #index' do
|
||||||
it 'Response code is 200' do
|
it 'Response code is 200' do
|
||||||
process :index, 'OPTIONS'
|
process :index, 'OPTIONS'
|
||||||
|
|
|
||||||
28
spec/controllers/schedules_controller_spec.rb
Normal file
28
spec/controllers/schedules_controller_spec.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe SchedulesController do
|
||||||
|
let(:conference) { create(:conference, splashpage: create(:splashpage, public: true), venue: create(:venue)) }
|
||||||
|
|
||||||
|
describe 'GET #show' do
|
||||||
|
context 'XML' do
|
||||||
|
before :each do
|
||||||
|
conference.program.schedule_public = true
|
||||||
|
conference.program.save!
|
||||||
|
create(:event_scheduled, program: conference.program)
|
||||||
|
create(:event_scheduled, program: conference.program)
|
||||||
|
|
||||||
|
get :show, conference_id: conference.short_title, format: :xml
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns variables' do
|
||||||
|
expect(assigns(:conference)).to eq conference
|
||||||
|
expect(assigns(:events_xml)).to eq conference.selected_event_schedules.map(&:event)
|
||||||
|
.group_by{ |event| event.scheduled_start_time.to_date }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders successfully' do
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue