2018-02-09 19:07:10 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-06-28 18:16:06 +03:00
|
|
|
class Survey < ActiveRecord::Base
|
|
|
|
|
belongs_to :surveyable, polymorphic: true
|
2018-02-09 19:07:10 +02:00
|
|
|
has_many :survey_questions, dependent: :destroy
|
|
|
|
|
has_many :survey_submissions, dependent: :destroy
|
2016-06-28 18:16:06 +03:00
|
|
|
|
|
|
|
|
enum target: [:after_conference, :during_registration]
|
|
|
|
|
validates :title, presence: true
|
|
|
|
|
|
|
|
|
|
def active?
|
2018-02-09 19:07:10 +02:00
|
|
|
return false unless start_date && end_date
|
2016-06-28 18:16:06 +03:00
|
|
|
now = Time.now.in_time_zone(surveyable.timezone)
|
|
|
|
|
now >= start_date && now <= end_date
|
|
|
|
|
end
|
|
|
|
|
end
|