From 5c26073af7b7a25af868437f50ae8caf8ff1418b Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 23 Jul 2024 14:31:22 +0200 Subject: [PATCH] small refacto with hidden_by_expired? method --- app/models/dossier.rb | 6 +++++- app/views/instructeurs/dossiers/_header_actions.html.haml | 2 +- app/views/instructeurs/procedures/show.html.haml | 2 +- app/views/users/dossiers/_dossiers_list.html.haml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 44c7a09e6..969ecc2fc 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -687,7 +687,7 @@ class Dossier < ApplicationRecord en_construction_close_to_expiration_notice_sent_at: nil, termine_close_to_expiration_notice_sent_at: nil) - if hidden_by_reason == 'expired' + if hidden_by_expired? update(hidden_by_expired_at: nil, hidden_by_reason: nil) restore(author) end @@ -782,6 +782,10 @@ class Dossier < ApplicationRecord !procedure.brouillon? && !brouillon? end + def hidden_by_expired? + hidden_by_expired_at.present? + end + def hidden_by_user? hidden_by_user_at.present? end diff --git a/app/views/instructeurs/dossiers/_header_actions.html.haml b/app/views/instructeurs/dossiers/_header_actions.html.haml index 84104ebee..69938b91d 100644 --- a/app/views/instructeurs/dossiers/_header_actions.html.haml +++ b/app/views/instructeurs/dossiers/_header_actions.html.haml @@ -8,7 +8,7 @@ dossier_is_followed: current_instructeur&.follow?(dossier), close_to_expiration: dossier.close_to_expiration?, hidden_by_administration: dossier.hidden_by_administration?, - hidden_by_expired: dossier.hidden_by_reason == 'expired', + hidden_by_expired: dossier.hidden_by_expired?, has_pending_correction: dossier.pending_correction?, has_blocking_pending_correction: dossier.procedure.feature_enabled?(:blocking_pending_correction) && dossier.pending_correction?, turbo: true, diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index d73df00cd..322017d97 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -173,7 +173,7 @@ dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id), close_to_expiration: @statut == 'expirant', hidden_by_administration: @statut == 'supprimes_recemment', - hidden_by_expired: p.hidden_by_reason == 'expired', + hidden_by_expired: p.hidden_by_expired?, sva_svr: @procedure.sva_svr_enabled?, has_blocking_pending_correction: @procedure.feature_enabled?(:blocking_pending_correction) && p.pending_correction?, turbo: false, diff --git a/app/views/users/dossiers/_dossiers_list.html.haml b/app/views/users/dossiers/_dossiers_list.html.haml index 827581775..62f8d38d8 100644 --- a/app/views/users/dossiers/_dossiers_list.html.haml +++ b/app/views/users/dossiers/_dossiers_list.html.haml @@ -16,7 +16,7 @@ %p.fr-icon--sm.fr-icon-user-line = demandeur_dossier(dossier) - - if dossier.hidden_by_reason == 'expired' + - if dossier.hidden_by_expired? %p.fr-icon--sm.fr-icon-delete-line = t('views.users.dossiers.dossiers_list.deleted_by_automatic', date: l(dossier.hidden_by_expired_at.to_date)) - elsif dossier.hidden_by_user?