Sha256: d469699edf218cb42f5d442b51ebceaf5bd902874e41496bea259d3dd874975b

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module Sis
  module Core
    class Application < ApplicationRecord
      include AASM

      # Gender types
      MALE = 'Male'.freeze
      FEMALE = 'Female'.freeze

      aasm column: :status do
        state :draft, initial: true
        state :submitted, :under_review, :accepted, :rejected, :selected_for_exam, :selected_for_admission

        event :submit do
          transitions from: :draft, to: :submitted
        end

        event :review do
          transitions from: %i[submitted rejected accepted], to: :under_review
        end

        event :accept do
          transitions from: :under_review, to: :accepted
        end

        event :reject do
          transitions from: :under_review, to: :rejected
        end

        event :select_for_exam do
          transitions from: :accepted, to: :selected_for_exam
        end

        event :select_for_admission do
          transitions from: :selected_for_exam, to: :selected_for_admission
        end
      end

      validates :status, presence: true
      validates :payment_information, presence: true, if: :payment_made

      belongs_to :applicant
      belongs_to :academic_programme
      belongs_to :application_setup

      delegate(:name, to: :academic_programme, prefix: true, allow_nil: false)
      delegate(:full_name, to: :applicant, prefix: true, allow_nil: false)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sis_core-1.0.10 app/models/sis/core/application.rb
sis_core-1.0.9 app/models/sis/core/application.rb
sis_core-1.0.8 app/models/sis/core/application.rb
sis_core-1.0.7 app/models/sis/core/application.rb