Sha256: 41d41c8e8bc2bee3b1312a50ec9503e7d534e4234088e57fffdfbd7641f09bd2

Contents?: true

Size: 938 Bytes

Versions: 4

Compression:

Stored size: 938 Bytes

Contents

class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
  mount_uploader :photo, PhotoUploader

  has_many :participants, class_name: 'Tramway::Event::Participant'
  has_many :participant_form_fields, class_name: 'Tramway::Event::ParticipantFormField'
  has_many :sections, class_name: 'Tramway::Event::Section'
  has_many :partakings, as: :part, class_name: 'Tramway::Event::Partaking'

  enumerize :status, default: :common, in: [ :common, :main ]

  scope :main_event, -> { where(status: :main) }

  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 < DateTime.now
    return :are_being_right_now if request_collecting_begin_date&.<(DateTime.now) && request_collecting_end_date&.>(DateTime.now)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tramway-event-1.8.2 app/models/tramway/event/event.rb
tramway-event-1.8.1.1 app/models/tramway/event/event.rb
tramway-event-1.8.1 app/models/tramway/event/event.rb
tramway-event-1.8 app/models/tramway/event/event.rb