Sha256: 7c815f5a5cb2d0b4d9d63aab0e3ad21fe725baddfee54c1132b5cad6924542ec

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

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

  aasm :participation_state, column: :participation_state do
    state :requested, initial: true
    state :prev_approved
    state :waiting
    state :rejected
    state :approved
    state :without_answer
    state :reserved

    event :previous_approve do
      transitions from: %i[requested without_answer waiting], to: :prev_approved
    end

    event :wait_for_decision do
      transitions from: %i[requested without_answer], to: :waiting
    end

    event :reserve do
      transitions from: %i[requested without_answer waiting], to: :reserved
    end

    event :reject do
      transitions from: %i[requested without_answer waiting prev_approved reserved], to: :rejected
    end

    event :approve do
      transitions from: %i[prev_approved reserved requested], to: :approved
    end

    event :not_got_answer do
      transitions from: :requested, to: :without_answer
    end

    event :return_to_requested do
      transitions from: %i[prev_approved rejected], to: :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

9 entries across 9 versions & 1 rubygems

Version Path
tramway-event-1.12.9.1 app/models/tramway/event/participant.rb
tramway-event-1.12.9 app/models/tramway/event/participant.rb
tramway-event-1.12.8.2 app/models/tramway/event/participant.rb
tramway-event-1.12.8.1 app/models/tramway/event/participant.rb
tramway-event-1.12.8 app/models/tramway/event/participant.rb
tramway-event-1.12.7 app/models/tramway/event/participant.rb
tramway-event-1.12.6.4 app/models/tramway/event/participant.rb
tramway-event-1.12.6.3 app/models/tramway/event/participant.rb
tramway-event-1.12.6.2 app/models/tramway/event/participant.rb