small refactos from Sim review
This commit is contained in:
parent
94e1f048ce
commit
df13e53815
3 changed files with 13 additions and 13 deletions
|
@ -651,12 +651,12 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def close_to_expiration?
|
||||
return false if en_instruction?
|
||||
expiration_notification_date < Time.zone.now && expiration_notification_date > Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago
|
||||
expiration_notification_date < Time.zone.now && Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago < expiration_notification_date
|
||||
end
|
||||
|
||||
def has_expired?
|
||||
return false if en_instruction?
|
||||
expiration_notification_date < Time.zone.now && expiration_notification_date < Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago
|
||||
expiration_notification_date < Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago
|
||||
end
|
||||
|
||||
def after_notification_expiration_date
|
||||
|
@ -836,27 +836,27 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def author_is_user(author)
|
||||
def is_user?(author)
|
||||
author.is_a?(User)
|
||||
end
|
||||
|
||||
def author_is_administration(author)
|
||||
def is_administration?(author)
|
||||
author.is_a?(Instructeur) || author.is_a?(Administrateur) || author.is_a?(SuperAdmin)
|
||||
end
|
||||
|
||||
def author_is_automatic(author)
|
||||
def is_automatic?(author)
|
||||
author == :automatic
|
||||
end
|
||||
|
||||
def hide_and_keep_track!(author, reason)
|
||||
transaction do
|
||||
if author_is_administration(author) && can_be_deleted_by_administration?(reason)
|
||||
if is_administration?(author) && can_be_deleted_by_administration?(reason)
|
||||
update(hidden_by_administration_at: Time.zone.now, hidden_by_reason: reason)
|
||||
log_dossier_operation(author, :supprimer, self)
|
||||
elsif author_is_user(author) && can_be_deleted_by_user?
|
||||
elsif is_user?(author) && can_be_deleted_by_user?
|
||||
update(hidden_by_user_at: Time.zone.now, dossier_transfer_id: nil, hidden_by_reason: reason)
|
||||
log_dossier_operation(author, :supprimer, self)
|
||||
elsif author_is_automatic(author) && can_be_deleted_by_automatic?(reason)
|
||||
elsif is_automatic?(author) && can_be_deleted_by_automatic?(reason)
|
||||
update(hidden_by_expired_at: Time.zone.now, hidden_by_reason: reason)
|
||||
log_automatic_dossier_operation(:supprimer, self)
|
||||
else
|
||||
|
@ -874,9 +874,9 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def restore(author)
|
||||
transaction do
|
||||
if author_is_administration(author)
|
||||
if is_administration?(author)
|
||||
update(hidden_by_administration_at: nil)
|
||||
elsif author_is_user(author)
|
||||
elsif is_user?(author)
|
||||
update(hidden_by_user_at: nil)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,5 +20,5 @@ fr:
|
|||
one: Vous pouvez télécharger votre dossier au format PDF depuis l’onglet « Expirant » sur la page
|
||||
other: "Vous pouvez télécharger vos dossiers au format PDF depuis l’onglet « Expirant » sur la page "
|
||||
footer_en_construction:
|
||||
one: Depuis la page de votre dossier vous avez la possibilité de :<br>- prolonger la durée de conservation pour un délai de 6 mois<br>- contacter l'administration qui gère votre dossier via la messagerie
|
||||
other: Depuis la page de vos dossiers vous avez la possibilité de :<br>- prolonger la durée de conservation pour un délai de 6 mois<br>- contacter l'administration qui gère votre dossier via la messagerie
|
||||
one: Depuis la page de votre dossier vous avez la possibilité de :<br>- prolonger la durée de conservation<br>- contacter l'administration qui gère votre dossier via la messagerie
|
||||
other: Depuis la page de vos dossiers vous avez la possibilité de :<br>- prolonger la durée de conservation<br>- contacter l'administration qui gère votre dossier via la messagerie
|
||||
|
|
|
@ -211,7 +211,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
expect(subject.body).to include("N° #{dossier.id} ")
|
||||
expect(subject.body).to include(dossier.procedure.libelle)
|
||||
expect(subject.body).to include("Votre compte reste activé")
|
||||
expect(subject.body).to include("Depuis la page de votre dossier vous avez la possibilité de :<br>- prolonger la durée de conservation pour un délai de 6 mois")
|
||||
expect(subject.body).to include("Depuis la page de votre dossier vous avez la possibilité de :<br>- prolonger la durée de conservation")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue