2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-04-03 17:05:54 +02:00
|
|
|
class DossierCorrection < ApplicationRecord
|
2023-02-28 15:06:39 +01:00
|
|
|
belongs_to :dossier
|
|
|
|
belongs_to :commentaire
|
2023-02-28 15:11:48 +01:00
|
|
|
|
2023-06-02 12:43:08 +02:00
|
|
|
validates_associated :commentaire
|
|
|
|
|
2023-02-28 15:11:48 +01:00
|
|
|
scope :pending, -> { where(resolved_at: nil) }
|
2023-06-02 15:46:23 +02:00
|
|
|
|
2023-11-22 17:10:37 +01:00
|
|
|
enum reason: {
|
|
|
|
incorrect: 'incorrect',
|
|
|
|
incomplete: 'incomplete',
|
|
|
|
outdated: 'outdated'
|
|
|
|
}, _prefix: :dossier
|
2023-06-14 13:13:30 +02:00
|
|
|
|
2023-06-02 15:46:23 +02:00
|
|
|
def resolved?
|
|
|
|
resolved_at.present?
|
|
|
|
end
|
2023-12-07 15:41:50 +01:00
|
|
|
|
|
|
|
def resolve
|
|
|
|
self.resolved_at = Time.current
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve!
|
|
|
|
resolve
|
|
|
|
save!
|
|
|
|
end
|
|
|
|
|
|
|
|
def pending? = !resolved?
|
2023-02-28 15:06:39 +01:00
|
|
|
end
|