app/models/tramway/event/event.rb in tramway-event-1.12.1 vs app/models/tramway/event/event.rb in tramway-event-1.12.1.1
- old
+ new
@@ -25,9 +25,12 @@
scope :actual, -> { order(:begin_date).where('end_date > ?', DateTime.now) }
scope :past, -> { where 'end_date < ?', DateTime.now }
scope :open, -> { where reach: :open }
scope :closed, -> { where reach: :closed }
+ validates :begin_date, presence: true
+ validates :end_date, presence: true
+
def request_collecting_state
return :not_initialized unless request_collecting_begin_date.present? || request_collecting_end_date.present?
return :will_begin_soon if request_collecting_begin_date > DateTime.now
return :is_over if request_collecting_end_date.present? && request_collecting_end_date.to_date < Date.today
return :are_being_right_now if request_collecting_begin_date&.past? && (request_collecting_end_date&.future? || request_collecting_end_date&.today?)