Introduces new RegistrationPeriod Object for Conference

#416
This commit is contained in:
Chrisbr 2014-08-18 14:33:02 +02:00
parent a620950383
commit ed55e2bf3a
25 changed files with 529 additions and 131 deletions

View file

@ -80,12 +80,10 @@ module Admin
@conference = Conference.find_by(short_title: params[:id])
short_title = @conference.short_title
@conference.assign_attributes(params[:conference])
send_mail_on_conf_update = @conference.notify_on_dates_change?
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
send_mail_on_conf_update = @conference.notify_on_dates_changed?
if @conference.update_attributes(params[:conference])
Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to(edit_admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.')
else

View file

@ -0,0 +1,57 @@
module Admin
class RegistrationPeriodsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference, singleton: true
def new
@registration_period = @conference.build_registration_period
end
def create
@registration_period = @conference.build_registration_period(registration_period)
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
if @registration_period.save
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
else
flash[:alert] = "A error prohibited the Registration Period from being saved: #{@registration_period.errors.full_messages.join('. ')}."
render :new
end
end
def edit
end
def show
end
def update
@registration_period.assign_attributes(registration_period)
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
if @registration_period.update(registration_period)
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
else
flash[:alert] = "A error prohibited the Registration Period from being saved: " \
"#{@registration_period.errors.full_messages.join('. ')}."
render :edit
end
end
def destroy
@registration_period.destroy
redirect_to admin_conference_registration_period_path,
notice: 'Registration Period was successfully destroyed.'
end
private
def registration_period
params[:registration_period]
end
end
end