2015-10-25 13:29:02 +02:00
|
|
|
module Admin
|
|
|
|
|
class ProgramsController < Admin::BaseController
|
|
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
|
|
|
load_and_authorize_resource through: :conference, singleton: true
|
|
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
|
|
def edit; end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
authorize! :update, @conference.program
|
|
|
|
|
@program = @conference.program
|
2016-01-13 14:15:12 +02:00
|
|
|
@program.assign_attributes(program_params)
|
2016-03-31 16:51:16 +02:00
|
|
|
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
2015-10-25 13:29:02 +02:00
|
|
|
|
2016-01-13 14:15:12 +02:00
|
|
|
if @program.update_attributes(program_params)
|
2016-04-21 16:16:16 +02:00
|
|
|
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_program_path(@conference.short_title),
|
|
|
|
|
notice: 'The program was successfully updated.'
|
2015-10-25 13:29:02 +02:00
|
|
|
else
|
|
|
|
|
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
|
|
|
|
render :new
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def program_params
|
2016-03-21 00:18:20 +01:00
|
|
|
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid, :languages)
|
2015-10-25 13:29:02 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|