Skip to content

Commit

Permalink
small refactos from Sim review
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand committed Jul 18, 2024
1 parent c26029c commit 5d67aea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,12 @@ def expiration_notification_date

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
Expand Down Expand Up @@ -841,27 +841,27 @@ def build_attestation
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
Expand All @@ -879,9 +879,9 @@ def hide_and_keep_track!(author, reason)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/mailers/dossier_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def notify_deletion_to_administration(hidden_dossier, to_email)
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

Expand Down

0 comments on commit 5d67aea

Please sign in to comment.