Implement track scheduling
Add track association to schedule Show schedules in admin sidebar to track organizers Allow track organizers to manage the schedules of their tracks Don't allow self-organized track events to be dragged or unscheduled in a conference schedule Make scheduled events of self-organized tracks appear semitransparent in conference schedules Make the rooms of confirmed self_organized tracks appear semitransparent and don't allow events to be scheduled to it in the conference schedules during the dates of its track Create admin/SchedulesController#new action Add a button in admin/Schedules#index to create schedules for tracks Add self_organized scope to Track Modify Schedules#show to handle track schedules and show a unified schedule Allow track organizers to create new schedules for their tracks Correctly identify scheduled and unscheduled events in Schedules#events Fix Event#room and Event#time for when the event is scheduled in a track schedule Modify Program#selected_event_schedules to include the event_schedules of selected track schedules Modify Track#revoke_role_and_cleanup to destroy the track's schedules and revert its events' state to new Add tabs for conference and track schedules in admin/Schedules#index Add button to Create/Show a tracks schedule in Tracks#index and #show Fix concurrent_events in application_helper because of changes in Program#selected_event_schedules Do not take into account cfp_active in Event#valid_track Modify EventsController#get_tracks accordingly Enforce cfp_active of track to be enabled for proposals in ProposalsController#create and #update Add support for multiple schedules per track Add selected_schedule_id to Track Load EventSchedules of selected track schedules for conference schedules in admin/SchedulesController#show Modify SchedulesController#show to take into account only the selected track schedules Create Event#selected_schedule_id and use it in Event#scheduled? and Event#time Validate that an EventSchedule for an event of a self-organized track belongs to one of the track's schedules Add 'Manage' button in Tracks#index, #show that sends you to the admin side of things Add admin/TracksController#update_selected_schedule to update the selected_schedule_id of tracks
This commit is contained in:
parent
af7efdb6fe
commit
7eea930269
37 changed files with 443 additions and 118 deletions
|
|
@ -198,7 +198,7 @@ module Admin
|
|||
end
|
||||
|
||||
def get_tracks
|
||||
@tracks = Track.accessible_by(current_ability).where(program: @program).confirmed.cfp_active
|
||||
@tracks = Track.accessible_by(current_ability).where(program: @program).confirmed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,14 +4,21 @@ module Admin
|
|||
# the schedule of a conference, which should not be accessed in the first place
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :program, through: :conference, singleton: true
|
||||
load_and_authorize_resource :schedule, through: :program
|
||||
load_and_authorize_resource :schedule, through: :program, except: [:new, :create]
|
||||
load_resource :event_schedules, through: :schedule
|
||||
load_resource :selected_schedule, through: :program, singleton: true
|
||||
load_resource :venue, through: :conference, singleton: true
|
||||
|
||||
def index; end
|
||||
|
||||
def new
|
||||
@schedule = @program.schedules.build(track: @program.tracks.new)
|
||||
authorize! :new, @schedule
|
||||
end
|
||||
|
||||
def create
|
||||
@schedule = @program.schedules.new(schedule_params)
|
||||
authorize! :create, @schedule
|
||||
if @schedule.save
|
||||
redirect_to admin_conference_schedule_path(@conference.short_title, @schedule.id),
|
||||
notice: 'Schedule was successfully created.'
|
||||
|
|
@ -23,9 +30,23 @@ module Admin
|
|||
|
||||
def show
|
||||
@event_schedules = @schedule.event_schedules
|
||||
@unscheduled_events = @program.events.confirmed - @schedule.events
|
||||
@dates = @conference.start_date..@conference.end_date
|
||||
@rooms = @conference.venue.rooms if @conference.venue
|
||||
|
||||
if @schedule.track
|
||||
track = @schedule.track
|
||||
@unscheduled_events = track.events.confirmed - @schedule.events
|
||||
@dates = track.start_date..track.end_date
|
||||
@rooms = [track.room]
|
||||
else
|
||||
@program.tracks.self_organized.confirmed.each do |t|
|
||||
@event_schedules += t.selected_schedule.event_schedules if t.selected_schedule
|
||||
end
|
||||
self_organized_tracks_events = @program.tracks.self_organized.confirmed.map do |t|
|
||||
t.events.confirmed
|
||||
end
|
||||
@unscheduled_events = @program.events.confirmed - @schedule.events - self_organized_tracks_events.flatten.compact
|
||||
@dates = @conference.start_date..@conference.end_date
|
||||
@rooms = @conference.venue.rooms if @conference.venue
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
@ -37,5 +58,11 @@ module Admin
|
|||
error: "Schedule couldn't be deleted. #{@schedule.errors.full_messages.join('. ')}."
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def schedule_params
|
||||
params.require(:schedule).permit(:track_id) if params[:schedule]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -101,6 +101,18 @@ module Admin
|
|||
update_state(:cancel, "Track #{@track.name} canceled!")
|
||||
end
|
||||
|
||||
def update_selected_schedule
|
||||
if @track.update_attributes(params.require(:track).permit(:selected_schedule_id))
|
||||
respond_to do |format|
|
||||
format.js { render json: {} }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js { render json: { errors: "The selected schedule couldn't been updated #{@track.errors.to_a.join('. ')}" }, status: 422 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_params
|
||||
|
|
|
|||
|
|
@ -49,6 +49,13 @@ class ProposalsController < ApplicationController
|
|||
# by default.
|
||||
@event.speakers = [current_user]
|
||||
@event.submitter = current_user
|
||||
|
||||
if Track.find_by(id: params[:event][:track_id]).try(:cfp_active) == false
|
||||
flash.now[:error] = 'You have selected a track that doesn\'t accept proposals'
|
||||
render action: 'new'
|
||||
return
|
||||
end
|
||||
|
||||
if @event.save
|
||||
ahoy.track 'Event submission', title: 'New submission'
|
||||
redirect_to conference_program_proposals_path(@conference.short_title), notice: 'Proposal was successfully submitted.'
|
||||
|
|
@ -61,6 +68,12 @@ class ProposalsController < ApplicationController
|
|||
def update
|
||||
@url = conference_program_proposal_path(@conference.short_title, params[:id])
|
||||
|
||||
if Track.find_by(id: params[:event][:track_id]).try(:cfp_active) == false
|
||||
flash.now[:error] = 'You have selected a track that doesn\'t accept proposals'
|
||||
render action: 'edit'
|
||||
return
|
||||
end
|
||||
|
||||
if @event.update(event_params)
|
||||
redirect_to conference_program_proposals_path(conference_id: @conference.short_title),
|
||||
notice: 'Proposal was successfully updated.'
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ class SchedulesController < ApplicationController
|
|||
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, @conference.end_hour)
|
||||
|
||||
# Ids of the schedules of confrmed self_organized tracks along with the selected_schedule_id
|
||||
@selected_schedules_ids = [@conference.program.selected_schedule_id]
|
||||
@conference.program.tracks.self_organized.confirmed.each do |track|
|
||||
@selected_schedules_ids << track.selected_schedule_id
|
||||
end
|
||||
@selected_schedules_ids.compact!
|
||||
end
|
||||
|
||||
def events
|
||||
|
|
@ -32,11 +39,7 @@ class SchedulesController < ApplicationController
|
|||
@events_schedules = @program.selected_event_schedules
|
||||
@events_schedules = [] unless @events_schedules
|
||||
|
||||
@unscheduled_events = if @program.selected_schedule
|
||||
@program.events.confirmed - @program.selected_schedule.events
|
||||
else
|
||||
@program.events.confirmed
|
||||
end
|
||||
@unscheduled_events = @program.events.confirmed - @events_schedules.map(&:event)
|
||||
|
||||
day = @conference.current_conference_day
|
||||
@tag = day.strftime('%Y-%m-%d') if day
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue