2014-08-06 21:14:00 +03:00
|
|
|
module Admin
|
2014-08-13 14:37:05 +03:00
|
|
|
class CallforpapersController < Admin::BaseController
|
2014-08-12 11:51:59 +03:00
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
|
|
|
# load_and_authorize_resource :cfp, class: 'CallForPapers', through: :conference
|
2013-01-07 09:04:09 +01:00
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def show
|
2014-08-12 11:51:59 +03:00
|
|
|
authorize! :show, CallForPapers.new(conference_id: @conference.id)
|
2014-08-06 21:14:00 +03:00
|
|
|
@cfp = @conference.call_for_papers
|
|
|
|
|
if @cfp.nil?
|
|
|
|
|
@cfp = CallForPapers.new
|
|
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
end
|
|
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def update
|
2014-08-12 11:51:59 +03:00
|
|
|
authorize! :update, @conference.call_for_papers
|
2014-08-06 21:14:00 +03:00
|
|
|
@cfp = @conference.call_for_papers
|
|
|
|
|
@cfp.assign_attributes(params[:call_for_papers])
|
2014-08-12 16:04:24 +05:30
|
|
|
send_mail_on_schedule_public = @cfp.notify_on_schedule_public?
|
2014-07-17 15:59:44 +05:30
|
|
|
|
2014-08-12 16:04:24 +05:30
|
|
|
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
|
2014-07-17 15:59:44 +05:30
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
if @cfp.update_attributes(params[:call_for_papers])
|
2014-08-12 16:04:24 +05:30
|
|
|
Mailbot.delay.send_on_call_for_papers_dates_updates(@conference) if send_mail_on_cfp_dates_updates
|
|
|
|
|
Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
|
2014-08-06 21:14:00 +03:00
|
|
|
redirect_to(admin_conference_callforpapers_path(
|
|
|
|
|
id: @conference.short_title),
|
|
|
|
|
notice: 'Call for Papers was successfully updated.')
|
|
|
|
|
else
|
|
|
|
|
redirect_to(admin_conference_callforpapers_path(
|
|
|
|
|
id: @conference.short_title),
|
2014-08-18 21:54:43 +03:00
|
|
|
alert: "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}.")
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2014-05-13 15:46:35 +02:00
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def create
|
2014-08-12 11:51:59 +03:00
|
|
|
authorize! :update, CallForPapers.new(conference_id: @conference.id)
|
2014-08-06 21:14:00 +03:00
|
|
|
@cfp = CallForPapers.new(params[:call_for_papers])
|
|
|
|
|
if @cfp.valid?
|
|
|
|
|
@cfp.save
|
|
|
|
|
@conference.call_for_papers = @cfp
|
|
|
|
|
redirect_to(admin_conference_callforpapers_path(
|
|
|
|
|
id: @conference.short_title),
|
|
|
|
|
notice: 'Call for Papers was successfully created.')
|
|
|
|
|
else
|
|
|
|
|
redirect_to(admin_conference_callforpapers_path(
|
|
|
|
|
id: @conference.short_title),
|
2014-08-18 21:54:43 +03:00
|
|
|
alert: "Creating the call for papers failed. #{@cfp.errors.to_a.join('. ')}.")
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|