From 2eb35065f8f556105cc02603229f7a6a8bd0d989 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Wed, 19 Jan 2022 14:34:28 +0100 Subject: [PATCH] fix dossier deletion mailers --- app/mailers/dossier_mailer.rb | 19 ++++--------------- app/models/dossier.rb | 9 --------- ...=> notify_deletion_to_administration.haml} | 0 .../notify_deletion_to_user.html.haml | 8 -------- ...ify_instructeur_deletion_to_user.html.haml | 8 -------- .../notify_deletion_to_user/fr.yml | 11 ----------- .../previews/dossier_mailer_preview.rb | 4 ---- 7 files changed, 4 insertions(+), 55 deletions(-) rename app/views/dossier_mailer/{notify_deletion_to_administration.html.haml => notify_deletion_to_administration.haml} (100%) delete mode 100644 app/views/dossier_mailer/notify_deletion_to_user.html.haml delete mode 100644 app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml delete mode 100644 config/locales/views/dossier_mailer/notify_deletion_to_user/fr.yml diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 3be44c460..645bb559e 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -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) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index d27fd4a1a..6e1a5adfc 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -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 diff --git a/app/views/dossier_mailer/notify_deletion_to_administration.html.haml b/app/views/dossier_mailer/notify_deletion_to_administration.haml similarity index 100% rename from app/views/dossier_mailer/notify_deletion_to_administration.html.haml rename to app/views/dossier_mailer/notify_deletion_to_administration.haml diff --git a/app/views/dossier_mailer/notify_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_deletion_to_user.html.haml deleted file mode 100644 index 55da5cfe9..000000000 --- a/app/views/dossier_mailer/notify_deletion_to_user.html.haml +++ /dev/null @@ -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" diff --git a/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml deleted file mode 100644 index f1959341f..000000000 --- a/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml +++ /dev/null @@ -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" diff --git a/config/locales/views/dossier_mailer/notify_deletion_to_user/fr.yml b/config/locales/views/dossier_mailer/notify_deletion_to_user/fr.yml deleted file mode 100644 index ea104b332..000000000 --- a/config/locales/views/dossier_mailer/notify_deletion_to_user/fr.yml +++ /dev/null @@ -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 l’administration. - 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 « %{libelle_demarche} » est supprimé.

- Cette suppression ne modifie pas le statut final (accepté, refusé ou sans suite) de votre dossier.

- Une trace de ce dossier est visible dans votre interface : %{deleted_dossiers_link}. diff --git a/spec/mailers/previews/dossier_mailer_preview.rb b/spec/mailers/previews/dossier_mailer_preview.rb index c85c0e6e0..739989da3 100644 --- a/spec/mailers/previews/dossier_mailer_preview.rb +++ b/spec/mailers/previews/dossier_mailer_preview.rb @@ -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