Sha256: b290265910b521f9a87635cb81fd4fa7c9b6f07f7b33f737db87252c402beb1a

Contents?: true

Size: 763 Bytes

Versions: 8

Compression:

Stored size: 763 Bytes

Contents

class ExamAuthorizationRequest < ApplicationRecord
  include TerminalNavigation

  belongs_to :exam
  belongs_to :user
  belongs_to :organization
  belongs_to :exam_registration

  enum status: %i(pending approved rejected)

  after_update :notify_user!

  def try_authorize!
    exam.authorize! user if approved?
  end

  def name
    exam_registration.description
  end

  def icon
    case status.to_sym
    when :pending
      { class: 'hourglass', type: 'info' }
    when :approved
      { class: 'check-circle', type: 'success' }
    when :rejected
      { class: 'times-circle', type: 'danger' }
    end
  end

  private

  def notify_user!
    Notification.create! organization: organization, user: user, target: self if saved_change_to_status?
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mumuki-domain-9.10.0 app/models/exam_authorization_request.rb
mumuki-domain-9.9.0 app/models/exam_authorization_request.rb
mumuki-domain-9.8.1 app/models/exam_authorization_request.rb
mumuki-domain-9.8.0 app/models/exam_authorization_request.rb
mumuki-domain-9.7.0 app/models/exam_authorization_request.rb
mumuki-domain-9.6.0 app/models/exam_authorization_request.rb
mumuki-domain-9.5.0 app/models/exam_authorization_request.rb
mumuki-domain-9.4.0 app/models/exam_authorization_request.rb