Add index view for the cfp and modify existing ones

Add cfp_type to the form partial
Refactor Cfps#show to use partials for the different cfp types
Modify the rest of the view, where the cfp was used
This commit is contained in:
AEtherC0r3 2017-05-31 21:03:15 +03:00 committed by Stella Rouzi
parent c3eb178546
commit 2bff918556
10 changed files with 107 additions and 67 deletions

View file

@ -4,21 +4,23 @@ module Admin
load_and_authorize_resource :program, through: :conference, singleton: true
load_and_authorize_resource through: :program
def index; end
def show; end
def new
@cfp = @program.build_cfp
@cfp = @program.cfps.new
end
def edit; end
def create
@cfp = @program.build_cfp(cfp_params)
@cfp = @program.cfps.new(cfp_params)
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
if @cfp.save
ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates
redirect_to admin_conference_program_cfp_path,
redirect_to admin_conference_program_cfps_path,
notice: 'Call for papers successfully created.'
else
flash.now[:error] = "Creating the call for papers failed. #{@cfp.errors.full_messages.join('. ')}."
@ -33,7 +35,7 @@ module Admin
if @cfp.update_attributes(cfp_params)
ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates
redirect_to admin_conference_program_cfp_path(@conference.short_title),
redirect_to admin_conference_program_cfps_path(@conference.short_title),
notice: 'Call for papers successfully updated.'
else
flash.now[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}."
@ -43,9 +45,9 @@ module Admin
def destroy
if @cfp.destroy
redirect_to admin_conference_program_cfp_path, notice: 'Call for Papers was successfully deleted.'
redirect_to admin_conference_program_cfps_path, notice: 'Call for Papers was successfully deleted.'
else
redirect_to admin_conference_program_cfp_path, error: 'An error prohibited this Call for Papers from being destroyed: '\
redirect_to admin_conference_program_cfps_path, error: 'An error prohibited this Call for Papers from being destroyed: '\
"#{@cfp.errors.full_messages.join('. ')}."
end
end
@ -53,7 +55,7 @@ module Admin
private
def cfp_params
params.require(:cfp).permit(:start_date, :end_date)
params.require(:cfp).permit(:start_date, :end_date, :cfp_type)
end
end
end