mirror of
https://github.com/openSUSE/osem.git
synced 2026-02-07 20:51:28 -05:00
Add roles as nested routes to track (for the track organizer role) Allow transition from to_accept to to_reject and backwards Split Track#valid_dates validation to many independent ones Show all the confirmed tracks in the conference's splashpage Add comment in admin/Tracks#toggle_cfp_inclusion Rewrite admin/TracksController#accept spec Add feature spec for track requests Change 'In' to 'Room' in Tracks#index Rewrite Track#overlapping Refactor code in ProposalsController Fix typos
70 lines
2.7 KiB
Ruby
70 lines
2.7 KiB
Ruby
module Admin
|
|
class SchedulesController < Admin::BaseController
|
|
# By authorizing 'conference' resource, we can ensure there will be no unauthorized access to
|
|
# 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, 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.'
|
|
else
|
|
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
|
error: "Could not create schedule. #{@schedule.errors.full_messages.join('. ')}."
|
|
end
|
|
end
|
|
|
|
def show
|
|
@event_schedules = @schedule.event_schedules
|
|
|
|
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
|
|
self_organized_tracks_events.flatten.compact!
|
|
@unscheduled_events = @program.events.confirmed - @schedule.events - self_organized_tracks_events
|
|
@dates = @conference.start_date..@conference.end_date
|
|
@rooms = @conference.venue.rooms if @conference.venue
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @schedule.destroy
|
|
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
|
notice: 'Schedule successfully deleted.'
|
|
else
|
|
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
|
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
|