update dossier after saving champ

update last_champ_updated_at without hook
update last_champ_private_updated_at without hook

Co-authored-by: Christophe Robillard <christophe.robillard@beta.gouv.fr>
This commit is contained in:
clemkeirua 2020-07-22 17:11:33 +02:00 committed by Christophe Robillard
parent b940d2e1b0
commit c772c3454c
4 changed files with 74 additions and 16 deletions

View file

@ -192,7 +192,11 @@ module Instructeurs
def update_annotations
dossier = current_instructeur.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
dossier.update(champs_private_params)
dossier.assign_attributes(champs_private_params)
if dossier.champs_private.any?(&:changed?)
dossier.last_champ_private_updated_at = Time.zone.now
end
dossier.save
dossier.modifier_annotations!(current_instructeur)
redirect_to annotations_privees_instructeur_dossier_path(procedure, dossier)
end

View file

@ -345,7 +345,11 @@ module Users
errors = []
if champs_params[:dossier]
if !@dossier.update(champs_params[:dossier])
@dossier.assign_attributes(champs_params[:dossier])
if @dossier.champs.any?(&:changed?)
@dossier.last_champ_updated_at = Time.zone.now
end
if !@dossier.save
errors += @dossier.errors.full_messages
elsif change_groupe_instructeur?
groupe_instructeur = @dossier.procedure.groupe_instructeurs.find(params[:dossier][:groupe_instructeur_id])