2014-08-10 21:17:06 +03:00
|
|
|
class Event < ActiveRecord::Base
|
2015-04-20 18:37:05 +03:00
|
|
|
include Proposable
|
|
|
|
|
2015-07-19 14:32:25 +03:00
|
|
|
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
|
|
|
has_one :conference, through: :track
|
2015-07-29 17:54:41 +03:00
|
|
|
|
|
|
|
has_many :participations
|
|
|
|
has_many :pending_participations, ->() { pending }, class_name: 'Participation'
|
|
|
|
has_many :approved_participations, ->() { approved }, class_name: 'Participation'
|
|
|
|
has_many :participants, through: :approved_participations
|
|
|
|
|
2015-07-19 20:01:52 +03:00
|
|
|
belongs_to :event_type
|
2015-07-19 14:32:25 +03:00
|
|
|
|
2014-08-10 21:17:06 +03:00
|
|
|
validates :title, presence: true
|
|
|
|
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
|
|
|
validates :abstract, presence: true
|
|
|
|
validates :description, presence: true
|
2014-09-04 00:39:54 +03:00
|
|
|
validates :agreement, acceptance: true
|
2015-04-20 18:37:14 +03:00
|
|
|
|
|
|
|
scope :confirmed, -> { where.not confirmed_at: nil }
|
2015-07-26 15:58:08 +03:00
|
|
|
|
|
|
|
def proposer_profile
|
|
|
|
proposer.personal_profile(conference)
|
|
|
|
end
|
2014-08-10 21:17:06 +03:00
|
|
|
end
|