Sha256: 763c1ccf6b7b8c2ffc27bf73d683d69c47e163696ce01dff4042219b88520e5e

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

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

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

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

    event :reject do
      transition [ :requested, :without_answer, :waiting, :prev_approved ] => :rejected
    end

    event :approve do
      transition prev_approved: :approved
    end

    event :not_got_answer do
      transition requested: :without_answer
    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 }
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tramway-event-1.8.1.1 app/models/tramway/event/participant.rb
tramway-event-1.8.1 app/models/tramway/event/participant.rb
tramway-event-1.8 app/models/tramway/event/participant.rb
tramway-event-1.7.2 app/models/tramway/event/participant.rb
tramway-event-1.7.1 app/models/tramway/event/participant.rb
tramway-event-1.7 app/models/tramway/event/participant.rb
tramway-event-1.6.4 app/models/tramway/event/participant.rb
tramway-event-1.6.3 app/models/tramway/event/participant.rb
tramway-event-1.6.2 app/models/tramway/event/participant.rb
tramway-event-1.6.1 app/models/tramway/event/participant.rb