Merge pull request #934 from nishanthvijayan/remove_call_for_paper

Remove unused call_for_paper model and controller files
This commit is contained in:
Stella Rouzi 2016-04-03 12:12:54 +03:00
commit c7576af0ba
2 changed files with 0 additions and 142 deletions

View file

@ -1,60 +0,0 @@
module Admin
class CallForPapersController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference, singleton: true
def show; end
def new
@call_for_paper = @conference.build_call_for_paper
end
def edit; end
def create
@call_for_paper = @conference.build_call_for_paper(call_for_paper_params)
if @call_for_paper.save
redirect_to admin_conference_call_for_paper_path,
notice: 'Call for papers successfully created.'
else
flash[:error] = "Creating the call for papers failed. #{@call_for_paper.errors.full_messages.join('. ')}."
render :new
end
end
def update
authorize! :update, @conference.call_for_paper
@cfp = @conference.call_for_paper
@cfp.assign_attributes(call_for_paper_params)
send_mail_on_schedule_public = @cfp.notify_on_schedule_public?
send_mail_on_cfp_dates_updated = @cfp.notify_on_cfp_date_update?
if @cfp.update_attributes(call_for_paper_params)
Mailbot.delay.send_on_call_for_papers_dates_updated(@conference) if send_mail_on_cfp_dates_updated
Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
redirect_to admin_conference_call_for_paper_path(@conference.short_title),
notice: 'Call for papers successfully updated.'
else
flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}."
render :new
end
end
def destroy
if @call_for_paper.destroy
redirect_to admin_conference_call_for_paper_path, notice: 'Call for Papers was successfully deleted.'
else
redirect_to admin_conference_call_for_paper_path, error: 'An error prohibited this Call for Papers from being destroyed: '\
"#{@call_for_paper.errors.full_messages.join('. ')}."
end
end
private
def call_for_paper_params
params.require(:call_for_paper).permit(:start_date, :end_date, :schedule_changes, :rating, :schedule_public, :include_cfp_in_splash, :conference_id)
end
end
end

View file

@ -1,82 +0,0 @@
class CallForPaper < ActiveRecord::Base
belongs_to :conference
validates_presence_of :start_date, :end_date
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
validate :before_end_of_conference
validate :start_after_end_date
##
# Calculates how many weeks the call for paper is.
#
# ====Returns
# * +Integer+ -> start week
def weeks
result = end_week - start_week + 1
weeks = Date.new(start_date.year, 12, 31).strftime('%W').to_i
result < 0 ? result + weeks : result
end
##
# Calculates the end week of the cfp
#
# ====Returns
def start_week
start_date.strftime('%W').to_i
end
##
# Calculates the end week of the cfp
#
# ====Returns
def end_week
end_date.strftime('%W').to_i
end
##
# Checks whether cfp dates is updated
#
# ====Returns
# * +True+ -> If cfp dates is updated and all other parameters are set
# * +False+ -> Either cfp date is not updated or one or more parameter is not set
def notify_on_cfp_date_update?
!self.end_date.blank? && !self.start_date.blank?\
&& (self.start_date_changed? || self.end_date_changed?)\
&& self.conference.email_settings.send_on_call_for_papers_dates_updated\
&& !self.conference.email_settings.call_for_papers_dates_updated_subject.blank?\
&& !self.conference.email_settings.call_for_papers_dates_updated_body.blank?
end
##
# Checks whether cfp dates is updated
#
# ====Returns
# * +True+ -> If cfp dates is updated and all other parameters are set
# * +False+ -> Either cfp date is not updated or one or more parameter is not set
def notify_on_schedule_public?
!self.end_date.blank? && !self.start_date.blank?\
&& (self.start_date_changed? || self.end_date_changed?)\
&& self.conference.email_settings.send_on_call_for_papers_dates_updated\
&& !self.conference.email_settings.call_for_papers_dates_updated_subject.blank?\
&& !self.conference.email_settings.call_for_papers_dates_updated_body.blank?
end
def remaining_days(date = Date.today)
result = (self.end_date - date).to_i
result > 0 ? result : 0
end
private
def before_end_of_conference
errors.
add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
errors.
add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
end
def start_after_end_date
errors.
add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
end
end