Sha256: 0f55fc7f86db28e68d50e4dc360cd87db2cfd7464733fa31e2f3869ba2d2533b

Contents?: true

Size: 1.54 KB

Versions: 70

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

class Tramway::Event::Participant < ::Tramway::Event::ApplicationRecord
  belongs_to :event, class_name: 'Tramway::Event::Event'

  state_machine :participation_state, initial: :requested do
    state :requested
    state :prev_approved
    state :waiting
    state :rejected
    state :approved
    state :without_answer
    state :reserved

    event :previous_approve do
      transition %i[requested without_answer waiting] => :prev_approved
    end

    event :wait_for_decision do
      transition %i[requested without_answer] => :waiting
    end

    event :reserve do
      transition %i[requested without_answer waiting] => :reserved
    end

    event :reject do
      transition %i[requested without_answer waiting prev_approved reserved] => :rejected
    end

    event :approve do
      transition %i[prev_approved reserved requested] => :approved
    end

    event :not_got_answer do
      transition requested: :without_answer
    end

    event :return_to_requested do
      transition %i[prev_approved rejected] => :requested
    end
  end

  scope :requested, -> { where participation_state: :requested }
  scope :waiting, -> { where participation_state: :waiting }
  scope :prev_approved, -> { where participation_state: :prev_approved }
  scope :rejected, -> { where participation_state: :rejected }
  scope :approved, -> { where participation_state: :approved }
  scope :without_answer, -> { where participation_state: :without_answer }
  scope :reserved, -> { where participation_state: :reserved }

  search_by :values
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
tramway-event-1.9.28.2 app/models/tramway/event/participant.rb
tramway-event-1.9.28.1 app/models/tramway/event/participant.rb
tramway-event-1.9.28 app/models/tramway/event/participant.rb
tramway-event-1.9.27.6 app/models/tramway/event/participant.rb
tramway-event-1.9.27.5 app/models/tramway/event/participant.rb
tramway-event-1.9.27.4 app/models/tramway/event/participant.rb
tramway-event-1.9.27.3 app/models/tramway/event/participant.rb
tramway-event-1.9.27.2 app/models/tramway/event/participant.rb
tramway-event-1.9.27.1 app/models/tramway/event/participant.rb
tramway-event-1.9.27 app/models/tramway/event/participant.rb
tramway-event-1.9.26 app/models/tramway/event/participant.rb
tramway-event-1.9.25.1 app/models/tramway/event/participant.rb
tramway-event-1.9.25 app/models/tramway/event/participant.rb
tramway-event-1.9.24.1 app/models/tramway/event/participant.rb
tramway-event-1.9.24 app/models/tramway/event/participant.rb
tramway-event-1.9.23.2 app/models/tramway/event/participant.rb
tramway-event-1.9.23.1 app/models/tramway/event/participant.rb
tramway-event-1.9.23 app/models/tramway/event/participant.rb
tramway-event-1.9.22 app/models/tramway/event/participant.rb
tramway-event-1.9.21.1 app/models/tramway/event/participant.rb