mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-14 20:24:03 +00:00
36 lines
873 B
Ruby
36 lines
873 B
Ruby
class CallForPapers < ActiveRecord::Base
|
|
attr_accessible :start_date, :end_date,
|
|
:description, :schedule_changes, :rating,
|
|
:schedule_public
|
|
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 }
|
|
|
|
##
|
|
# 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_week.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
|
|
end
|