Schedule update moved to program update

Schedule update updated a program attribute
This commit is contained in:
Ana 2016-08-04 19:20:11 +02:00
parent 310c521790
commit 81108290e5
4 changed files with 41 additions and 22 deletions

View file

@ -13,20 +13,28 @@ module Admin
@program.assign_attributes(program_params)
send_mail_on_schedule_public = @program.notify_on_schedule_public?
if @program.update_attributes(program_params)
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
redirect_to admin_conference_program_path(@conference.short_title),
notice: 'The program was successfully updated.'
else
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
render :new
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)
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid, :languages, :blind_voting, :voting_start_date, :voting_end_date, :selected_schedule_id)
end
end
end