Merge pull request #9882 from demarches-simplifiees/add-dossier-reference-in-transfer-email

Je veux que le numéro du dossier apparaisse dans l'email de demande de transfert
This commit is contained in:
Lisa Durand 2024-01-15 15:39:09 +00:00 committed by GitHub
commit d9b75ce0a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 13 deletions

View file

@ -164,7 +164,7 @@ class DossierMailer < ApplicationMailer
def notify_transfer(transfer) def notify_transfer(transfer)
I18n.with_locale(transfer.user_locale) do I18n.with_locale(transfer.user_locale) do
@subject = default_i18n_subject(count: transfer.dossiers.size) @subject = default_i18n_subject()
@transfer = transfer @transfer = transfer
mail(to: transfer.email, subject: @subject) mail(to: transfer.email, subject: @subject)

View file

@ -58,6 +58,18 @@ class DossierTransfer < ApplicationRecord
end end
end end
def sender
if from_support?
I18n.t("views.users.dossiers.transfers.sender_from_support")
else
sender_email
end
end
def sender_email
dossiers.last.user.email
end
private private
def send_notification def send_notification

View file

@ -1,9 +1,16 @@
- content_for(:title, "#{@subject}")
%p= t(:hello, scope: [:views, :shared, :greetings]) %p= t(:hello, scope: [:views, :shared, :greetings])
%p %p
= t('.body', count: @transfer.dossiers.size) - if @transfer.dossiers.size > 1
= t('.transfert_multiple', sender: @transfer.sender, count: @transfer.dossiers.size)
- else
- dossier = @transfer.dossiers.last
= t('.transfert_simple', sender: @transfer.sender, dossier_id: dossier.id)
%span{ :style => "font-weight: bold;" }
= dossier.procedure.libelle
%p
= t('.transfer_text')
= link_to t('.transfer_link'), dossiers_url(statut: 'dossiers-transferes') = link_to t('.transfer_link'), dossiers_url(statut: 'dossiers-transferes')
= render partial: "layouts/mailers/signature" = render partial: "layouts/mailers/signature"

View file

@ -490,8 +490,9 @@ en:
deleted: Deleted at %{date} deleted: Deleted at %{date}
deleted_badge: Deleted deleted_badge: Deleted
transfers: transfers:
sender_from_support: Technical support
sender_demande_en_cours: "A transfer request is pending on file Nº %{id} to %{email}" sender_demande_en_cours: "A transfer request is pending on file Nº %{id} to %{email}"
sender_demande_en_cours: "A transfer request from technical support is pending on file Nº %{id} to %{email}" sender_demande_en_cours_from_support: "A transfer request from technical support is pending on file Nº %{id} to %{email}"
receiver_demande_en_cours: "Transfer request on file Nº %{id} sent by %{email}" receiver_demande_en_cours: "Transfer request on file Nº %{id} sent by %{email}"
receiver_demande_en_cours_from_support: "Transfer request from technical support on file Nº %{id} of %{email}" receiver_demande_en_cours_from_support: "Transfer request from technical support on file Nº %{id} of %{email}"
revoke: Revoke this request revoke: Revoke this request

View file

@ -504,6 +504,7 @@ fr:
actions: "Actions" actions: "Actions"
other_actions: "Autres actions" other_actions: "Autres actions"
transfers: transfers:
sender_from_support: Le support technique
sender_demande_en_cours: "Une demande de transfert est en cours sur le dossier Nº %{id} pour %{email}" sender_demande_en_cours: "Une demande de transfert est en cours sur le dossier Nº %{id} pour %{email}"
sender_demande_en_cours_from_support: "Une demande de transfert par le support technique est en cours sur le dossier Nº %{id} pour %{email}" sender_demande_en_cours_from_support: "Une demande de transfert par le support technique est en cours sur le dossier Nº %{id} pour %{email}"
receiver_demande_en_cours: "Demande de transfert pour le dossier Nº %{id} envoyé par %{email}" receiver_demande_en_cours: "Demande de transfert pour le dossier Nº %{id} envoyé par %{email}"

View file

@ -0,0 +1,8 @@
en:
dossier_mailer:
notify_transfer:
subject: You have a pending transfer request.
transfer_text: "Access the transfer request by clicking on the following link:"
transfer_link: transfer request
transfert_multiple: "%{sender} sends you a transfer request for %{count} files."
transfert_simple: "%{sender} sends you a transfer request for file no. %{dossier_id} on the procedure"

View file

@ -1,12 +1,8 @@
fr: fr:
dossier_mailer: dossier_mailer:
notify_transfer: notify_transfer:
subject: subject: Vous avez une demande de transfert en attente.
one: Une demande de transfert de dossier vous est adressée transfer_text: "Accéder à la demande de transfert en cliquant sur le lien suivant :"
other: Une demande de transfert de dossiers vous est adressée
transfer_link: demande de transfert transfer_link: demande de transfert
body: transfert_multiple: "%{sender} vous adresse une demande de transfert pour %{count} dossiers."
one: | transfert_simple: "%{sender} vous adresse une demande de transfert pour le dossier n° %{dossier_id} sur la démarche"
Accéder à la demande de transfert du dossier en cliquant sur le lien suivant :
other: |
Accéder à la demande de transfert de %{count} dossiers en cliquant sur le lien suivant :

View file

@ -265,4 +265,34 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include("réinitialisé") } it { expect(subject.body).to include("réinitialisé") }
end end
end end
describe 'notify_transfer' do
let(:user) { create(:user) }
let(:procedure) { create(:procedure) }
let(:dossier_transfer) { create(:dossier_transfer) }
let!(:dossier) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
subject { described_class.notify_transfer(dossier_transfer) }
context 'when it is a transfer of one dossier' do
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour le dossier n° #{dossier.id} sur la démarche") }
it { expect(subject.body).to include(procedure.libelle.to_s) }
end
context 'when it is a transfer of multiple dossiers' do
let!(:dossier2) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour 2 dossiers.") }
end
context 'when it is a transfer of one dossier from super admin' do
before do
dossier_transfer.update!(from_support: true)
end
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("Le support technique vous adresse une demande de transfert") }
end
end
end end