2013-01-07 09:04:09 +01:00
|
|
|
class CallForPapers < ActiveRecord::Base
|
2014-06-04 16:47:50 +02:00
|
|
|
attr_accessible :start_date, :end_date,
|
2014-05-14 16:37:19 +02:00
|
|
|
:description, :schedule_changes, :rating,
|
2014-06-17 20:25:35 +05:30
|
|
|
:schedule_public, :include_cfp_in_splash
|
2013-01-07 09:04:09 +01:00
|
|
|
belongs_to :conference
|
|
|
|
|
|
2014-06-04 16:47:50 +02:00
|
|
|
validates_presence_of :start_date, :end_date
|
2014-07-21 14:49:05 +02:00
|
|
|
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
2013-01-07 09:04:09 +01:00
|
|
|
|
2014-06-02 12:37:57 +02:00
|
|
|
##
|
|
|
|
|
# Calculates how many weeks the call for paper is.
|
|
|
|
|
#
|
|
|
|
|
# ====Returns
|
|
|
|
|
# * +Integer+ -> start week
|
|
|
|
|
def weeks
|
|
|
|
|
result = end_week - start_week + 1
|
2014-06-12 21:07:07 +03:00
|
|
|
weeks = Date.new(start_date.year, 12, 31).strftime('%W').to_i
|
2014-06-02 12:37:57 +02:00
|
|
|
result < 0 ? result + weeks : result
|
2014-05-30 10:10:47 +02:00
|
|
|
end
|
|
|
|
|
|
2014-06-02 12:37:57 +02:00
|
|
|
##
|
|
|
|
|
# Calculates the end week of the cfp
|
|
|
|
|
#
|
|
|
|
|
# ====Returns
|
2014-05-30 10:10:47 +02:00
|
|
|
def start_week
|
|
|
|
|
start_date.strftime('%W').to_i
|
|
|
|
|
end
|
|
|
|
|
|
2014-06-02 12:37:57 +02:00
|
|
|
##
|
|
|
|
|
# Calculates the end week of the cfp
|
|
|
|
|
#
|
|
|
|
|
# ====Returns
|
2014-05-30 10:10:47 +02:00
|
|
|
def end_week
|
|
|
|
|
end_date.strftime('%W').to_i
|
|
|
|
|
end
|
2013-08-16 16:09:29 +03:00
|
|
|
end
|