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.12.6 app/models/tramway/event/participant.rb
tramway-event-1.12.5 app/models/tramway/event/participant.rb
tramway-event-1.12.4 app/models/tramway/event/participant.rb
tramway-event-1.12.3.10 app/models/tramway/event/participant.rb
tramway-event-1.12.3.9 app/models/tramway/event/participant.rb
tramway-event-1.12.3.8 app/models/tramway/event/participant.rb
tramway-event-1.12.3.7 app/models/tramway/event/participant.rb
tramway-event-1.12.3.6 app/models/tramway/event/participant.rb
tramway-event-1.12.3.5 app/models/tramway/event/participant.rb
tramway-event-1.12.3.4 app/models/tramway/event/participant.rb
tramway-event-1.12.3.3 app/models/tramway/event/participant.rb
tramway-event-1.12.3.2 app/models/tramway/event/participant.rb
tramway-event-1.12.3.1 app/models/tramway/event/participant.rb
tramway-event-1.12.3 app/models/tramway/event/participant.rb
tramway-event-1.12.2 app/models/tramway/event/participant.rb
tramway-event-1.12.1.1 app/models/tramway/event/participant.rb
tramway-event-1.12.1 app/models/tramway/event/participant.rb
tramway-event-1.12.0.1 app/models/tramway/event/participant.rb
tramway-event-1.12 app/models/tramway/event/participant.rb
tramway-event-1.11.5.1 app/models/tramway/event/participant.rb