refactor(dossier): use touch
This commit is contained in:
parent
7932085976
commit
c2c26719d3
4 changed files with 12 additions and 6 deletions
|
@ -30,8 +30,14 @@ class Champs::PieceJustificativeController < Champs::ChampController
|
|||
save_succeed = @champ.save
|
||||
end
|
||||
|
||||
@champ.dossier.update(last_champ_updated_at: Time.zone.now.utc) if save_succeed
|
||||
if save_succeed && dossier.brouillon?
|
||||
dossier.touch(:last_champ_updated_at, :last_champ_piece_jointe_updated_at)
|
||||
end
|
||||
|
||||
save_succeed
|
||||
end
|
||||
|
||||
def dossier
|
||||
@champ.dossier
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,7 +57,7 @@ module CreateAvisConcern
|
|||
persisted, failed = create_results.partition(&:persisted?)
|
||||
|
||||
if persisted.any?
|
||||
dossier.update!(last_avis_updated_at: Time.zone.now)
|
||||
dossier.touch(:last_avis_updated_at)
|
||||
sent_emails_addresses = []
|
||||
persisted.each do |avis|
|
||||
avis.dossier.demander_un_avis!(avis)
|
||||
|
|
|
@ -250,7 +250,7 @@ module Instructeurs
|
|||
|
||||
if commentaire.valid?
|
||||
dossier.flag_as_pending_correction!(commentaire, params[:reason].presence)
|
||||
dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
||||
dossier.touch(:last_commentaire_updated_at)
|
||||
current_instructeur.follow(dossier)
|
||||
|
||||
flash.notice = "Dossier marqué comme en attente de correction."
|
||||
|
@ -275,7 +275,7 @@ module Instructeurs
|
|||
@commentaire = CommentaireService.create(current_instructeur, dossier, commentaire_params)
|
||||
|
||||
if @commentaire.errors.empty?
|
||||
@commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
||||
@commentaire.dossier.touch(:last_commentaire_updated_at)
|
||||
current_instructeur.follow(dossier)
|
||||
flash.notice = "Message envoyé"
|
||||
redirect_to messagerie_instructeur_dossier_path(procedure, dossier)
|
||||
|
@ -300,7 +300,7 @@ module Instructeurs
|
|||
def update_annotations
|
||||
dossier_with_champs.update_champs_attributes(champs_private_attributes_params, :private, updated_by: current_user.email)
|
||||
if dossier.champs.any?(&:changed_for_autosave?)
|
||||
dossier.last_champ_private_updated_at = Time.zone.now
|
||||
dossier.touch(:last_champ_private_updated_at)
|
||||
end
|
||||
|
||||
dossier.save(context: :champs_private_value)
|
||||
|
|
|
@ -237,7 +237,7 @@ module Instructeurs
|
|||
dossiers.each do |dossier|
|
||||
commentaire = CommentaireService.create(current_instructeur, dossier, bulk_message_params.except(:targets))
|
||||
if commentaire.errors.empty?
|
||||
commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
||||
commentaire.dossier.touch(:last_commentaire_updated_at)
|
||||
else
|
||||
errors << dossier.id
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue