Sha256: fa973f5d7705e6ff8fbabe42f233f50a4c0720cb2e11288f062a7f14e0d97108

Contents?: true

Size: 831 Bytes

Versions: 16

Compression:

Stored size: 831 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_and_notify_via_email! organization: organization, user: user, target: self, subject: 'exam_authorization_request_updated' if saved_change_to_status?
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/exam_authorization_request.rb
mumuki-domain-9.22.1 app/models/exam_authorization_request.rb
mumuki-domain-9.22.0 app/models/exam_authorization_request.rb
mumuki-domain-9.21.0 app/models/exam_authorization_request.rb
mumuki-domain-9.20.0 app/models/exam_authorization_request.rb
mumuki-domain-9.19.0 app/models/exam_authorization_request.rb
mumuki-domain-9.18.0 app/models/exam_authorization_request.rb
mumuki-domain-9.17.0 app/models/exam_authorization_request.rb
mumuki-domain-9.16.0 app/models/exam_authorization_request.rb
mumuki-domain-9.15.0 app/models/exam_authorization_request.rb
mumuki-domain-9.14.1 app/models/exam_authorization_request.rb
mumuki-domain-9.14.0 app/models/exam_authorization_request.rb
mumuki-domain-9.13.1 app/models/exam_authorization_request.rb
mumuki-domain-9.13.0 app/models/exam_authorization_request.rb
mumuki-domain-9.12.0 app/models/exam_authorization_request.rb
mumuki-domain-9.11.0 app/models/exam_authorization_request.rb