fix dossier deletion mailers

This commit is contained in:
Kara Diaby 2022-01-19 14:34:28 +01:00
parent 4b9bc582e7
commit 2eb35065f8
7 changed files with 4 additions and 55 deletions

View file

@ -84,22 +84,11 @@ class DossierMailer < ApplicationMailer
mail(to: to_email, subject: @subject)
end
def notify_deletion_to_user(deleted_dossier, to_email)
I18n.with_locale(deleted_dossier.user_locale) do
@subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id)
@deleted_dossier = deleted_dossier
def notify_en_construction_deletion_to_administration(dossier, to_email)
@subject = default_i18n_subject(dossier_id: dossier.id)
@dossier = dossier
mail(to: to_email, subject: @subject)
end
end
def notify_instructeur_deletion_to_user(deleted_dossier, to_email)
I18n.with_locale(deleted_dossier.user_locale) do
@subject = default_i18n_subject(libelle_demarche: deleted_dossier.procedure.libelle)
@deleted_dossier = deleted_dossier
mail(to: to_email, subject: @subject)
end
mail(to: to_email, subject: @subject)
end
def notify_deletion_to_administration(deleted_dossier, to_email)

View file

@ -774,7 +774,6 @@ class Dossier < ApplicationRecord
update(hidden_by_user_at: Time.zone.now, dossier_transfer_id: nil)
end
user_email = user_deleted? ? nil : user_email_for(:notification)
deleted_dossier = nil
transaction do
@ -797,14 +796,6 @@ class Dossier < ApplicationRecord
DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later
end
end
if user_email.present?
if reason == :user_request
DossierMailer.notify_deletion_to_user(deleted_dossier, user_email).deliver_later
else
DossierMailer.notify_instructeur_deletion_to_user(deleted_dossier, user_email).deliver_later
end
end
end
end

View file

@ -1,8 +0,0 @@
- content_for(:title, "#{@subject}")
%p= t(:hello, scope: [:views, :shared, :greetings])
%p
= t('.body', dossier_id: @deleted_dossier.dossier_id, procedure: @deleted_dossier.procedure.libelle)
= render partial: "layouts/mailers/signature"

View file

@ -1,8 +0,0 @@
- content_for(:title, "#{@subject}")
%p= t(:hello, scope: [:views, :shared, :greetings])
%p
= t('.body_html', dossier_id: @deleted_dossier.dossier_id, libelle_demarche: @deleted_dossier.procedure.libelle, deleted_dossiers_link: dossiers_url(statut: 'dossiers-supprimes'))
= render partial: "layouts/mailers/signature"

View file

@ -1,11 +0,0 @@
fr:
dossier_mailer:
notify_deletion_to_user:
subject: Votre dossier nº %{dossier_id} a bien été supprimé
body: Votre dossier n° %{dossier_id} (%{procedure}) a bien été supprimé. Une trace de ce traitement sera conservée pour ladministration.
notify_instructeur_deletion_to_user:
subject: Votre dossier sur la démarche « %{libelle_demarche} » est supprimé
body_html: |
Afin de limiter la conservation de vos données personnelles, votre dossier n° %{dossier_id} concernant la démarche <b>« %{libelle_demarche} »</b> est <b>supprimé</b>.<br><br>
Cette suppression ne modifie pas le statut final (accepté, refusé ou sans suite) de votre dossier.<br><br>
Une trace de ce dossier est visible dans votre interface : <a href='%{deleted_dossiers_link}'>%{deleted_dossiers_link}</a>.

View file

@ -45,10 +45,6 @@ class DossierMailerPreview < ActionMailer::Preview
DossierMailer.notify_brouillon_deletion(dossier_hashes, usager_email)
end
def notify_deletion_to_user
DossierMailer.notify_deletion_to_user(deleted_dossier, usager_email)
end
def notify_instructeur_deletion_to_user
DossierMailer.notify_instructeur_deletion_to_user(deleted_dossier, usager_email)
end