diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index d7ebd707868..ae148d2583a 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -25,6 +25,8 @@ def extend_conservation def extend_conservation_and_restore dossier.extend_conservation_and_restore(1.month, current_instructeur) + flash[:notice] = t('views.instructeurs.dossiers.archived_dossier') + redirect_back(fallback_location: instructeur_dossier_path(@dossier.procedure, @dossier)) end def geo_data @@ -380,7 +382,7 @@ def dossier_scope Dossier .where(id: current_instructeur.dossiers.visible_by_administration) .or(Dossier.where(id: current_user.dossiers.for_procedure_preview)) - elsif action_name == 'extend_conservation' + elsif action_name == 'extend_conservation_and_restore' Dossier .where(id: current_instructeur.dossiers.visible_by_administration) .or(Dossier.where(id: current_instructeur.dossiers.hidden_by_expired)) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 79e244ecc59..49b3e0dba2b 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -260,7 +260,9 @@ def extend_conservation end def extend_conservation_and_restore - dossier.extend_conservation_and_restore(conservation_extension, author) + dossier.extend_conservation_and_restore(dossier.procedure.duree_conservation_dossiers_dans_ds.months, current_user) + flash[:notice] = t('views.users.dossiers.archived_dossier', duree_conservation_dossiers_dans_ds: dossier.procedure.duree_conservation_dossiers_dans_ds) + redirect_back(fallback_location: dossier_path(@dossier)) end def modifier @@ -534,7 +536,7 @@ def dossier_scope Dossier.visible_by_user.or(Dossier.for_procedure_preview).or(Dossier.for_editing_fork) elsif action_name == 'restore' Dossier.hidden_by_user - elsif action_name == 'extend_conservation' + elsif action_name == 'extend_conservation' || action_name == 'extend_conservation_and_restore' Dossier.visible_by_user.or(Dossier.hidden_by_expired) else Dossier.visible_by_user diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0d71af6cb91..63bbb2c59c3 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -691,7 +691,7 @@ def extend_conservation(conservation_extension) def extend_conservation_and_restore(conservation_extension, author) extend_conservation(conservation_extension) update(hidden_by_expired_at: nil, hidden_by_reason: nil) - restore(current_user) + restore(author) end def show_procedure_state_warning? diff --git a/app/views/users/dossiers/_dossiers_list.html.haml b/app/views/users/dossiers/_dossiers_list.html.haml index a7f93a63735..7a7ff4c841f 100644 --- a/app/views/users/dossiers/_dossiers_list.html.haml +++ b/app/views/users/dossiers/_dossiers_list.html.haml @@ -108,7 +108,7 @@ - else - if dossier.expiration_can_be_extended? - = button_to users_dossier_extend_conservation_and_restore_path(dossier), class: 'fr-btn fr-btn--sm' do + = button_to users_dossier_repousser_expiration_and_restore_path(dossier), class: 'fr-btn fr-btn--sm' do Restaurer et étendre la conservation diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index a9deb47238a..7ee366e4962 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -1308,7 +1308,7 @@ end describe '#extend_conservation and restore' do - subject { post :extend_conservation, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + subject { post :extend_conservation_and_restore, params: { procedure_id: procedure.id, dossier_id: dossier.id } } before do dossier.update(hidden_by_expired_at: 1.hour.ago, hidden_by_reason: 'expired')