Merge pull request #9818 from colinux/correction-remove-from-message
ETQ instructeur, ma demande de correction est supprimée (résolue) lorsque je supprime son message associé
This commit is contained in:
commit
968b2cfb0a
10 changed files with 72 additions and 9 deletions
|
@ -74,9 +74,13 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def soft_delete!
|
||||
transaction do
|
||||
discard!
|
||||
dossier_correction&.resolve!
|
||||
update! body: ''
|
||||
end
|
||||
|
||||
piece_jointe.purge_later if piece_jointe.attached?
|
||||
discard!
|
||||
update! body: ''
|
||||
end
|
||||
|
||||
def flagged_pending_correction?
|
||||
|
|
|
@ -41,9 +41,7 @@ module DossierCorrectableConcern
|
|||
end
|
||||
|
||||
def resolve_pending_correction
|
||||
return if pending_correction.nil?
|
||||
|
||||
pending_correction.resolved_at = Time.current
|
||||
pending_correction&.resolve
|
||||
end
|
||||
|
||||
def resolve_pending_correction!
|
||||
|
|
|
@ -15,4 +15,15 @@ class DossierCorrection < ApplicationRecord
|
|||
def resolved?
|
||||
resolved_at.present?
|
||||
end
|
||||
|
||||
def resolve
|
||||
self.resolved_at = Time.current
|
||||
end
|
||||
|
||||
def resolve!
|
||||
resolve
|
||||
save!
|
||||
end
|
||||
|
||||
def pending? = !resolved?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue