small refacto with hidden_by_expired? method

This commit is contained in:
Lisa Durand 2024-07-23 14:31:22 +02:00
parent df13e53815
commit 5c26073af7
No known key found for this signature in database
GPG key ID: 0DF91F2CA1E8B816
4 changed files with 8 additions and 4 deletions

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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?