osem-fcy/app/controllers/admin/programs_controller.rb
Ana 81108290e5 Schedule update moved to program update
Schedule update updated a program attribute
2016-08-11 15:11:27 +02:00

40 lines
1.3 KiB
Ruby

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
@program.assign_attributes(program_params)
send_mail_on_schedule_public = @program.notify_on_schedule_public?
respond_to do |format|
if @program.update_attributes(program_params)
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
format.html do
redirect_to admin_conference_program_path(@conference.short_title),
notice: 'The program was successfully updated.'
end
format.js { render json: { 'status' => 'ok' } }
else
format.html do
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
render :new
end
format.js { render json: { 'status' => 'error' } }
end
end
end
private
def program_params
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid, :languages, :blind_voting, :voting_start_date, :voting_end_date, :selected_schedule_id)
end
end
end