Sha256: 6f032de201ff7ff9aadf0fae146bb37a6d52a026a658da99a013b8337bdda37f

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 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
    state :reserved

    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, :reserved ] => :approved
    end

    event :not_got_answer do
      transition requested: :without_answer
    end

    event :reserve do
      transition [ :requested, :without_answer, :waiting ] => :reserved
    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 }

  pg_search_scope :search, against: [:values]
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tramway-event-1.9.11.2 app/models/tramway/event/participant.rb
tramway-event-1.9.11.1 app/models/tramway/event/participant.rb
tramway-event-1.9.11 app/models/tramway/event/participant.rb
tramway-event-1.9.10.1 app/models/tramway/event/participant.rb
tramway-event-1.9.10 app/models/tramway/event/participant.rb