diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index cb1f8f772..4be072ee7 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -5,61 +5,73 @@ class DossierMailer < ApplicationMailer helper ProcedureHelper layout 'mailers/layout' + default from: NO_REPLY_EMAIL def notify_new_draft(dossier) - @dossier = dossier - @service = dossier.procedure.service - @logo_url = attach_logo(dossier.procedure) + I18n.with_locale(dossier.user_locale) do + @dossier = dossier + @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) + @subject = default_i18n_subject(libelle_demarche: dossier.procedure.libelle) - subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »" - - mail(from: NO_REPLY_EMAIL, to: dossier.user_email_for(:notification), subject: subject) do |format| - format.html { render layout: 'mailers/notifications_layout' } + mail(to: dossier.user_email_for(:notification), subject: @subject) do |format| + format.html { render layout: 'mailers/notifications_layout' } + end end end def notify_new_answer(dossier, body = nil) - @dossier = dossier - @service = dossier.procedure.service - @logo_url = attach_logo(dossier.procedure) - @body = body + I18n.with_locale(dossier.user_locale) do + @dossier = dossier + @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) + @body = body + @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) - subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})" - - mail(from: NO_REPLY_EMAIL, to: dossier.user_email_for(:notification), subject: subject) do |format| - format.html { render layout: 'mailers/notifications_layout' } + mail(to: dossier.user_email_for(:notification), subject: @subject) do |format| + format.html { render layout: 'mailers/notifications_layout' } + end end end def notify_new_commentaire_to_instructeur(dossier, instructeur_email) - @dossier = dossier - @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) - mail(from: NO_REPLY_EMAIL, to: instructeur_email, subject: @subject) + I18n.with_locale(dossier.user_locale) do + @dossier = dossier + @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) + + mail(to: instructeur_email, subject: @subject) + end end def notify_new_dossier_depose_to_instructeur(dossier, instructeur_email) - @dossier = dossier - @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) - mail(from: NO_REPLY_EMAIL, to: instructeur_email, subject: @subject) + I18n.with_locale(dossier.user_locale) do + @dossier = dossier + @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) + + mail(to: instructeur_email, subject: @subject) + end end def notify_revert_to_instruction(dossier) - @dossier = dossier - @service = dossier.procedure.service - @logo_url = attach_logo(dossier.procedure) + I18n.with_locale(dossier.user_locale) do + @dossier = dossier + @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) + @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) - subject = "Votre dossier nº #{@dossier.id} est en train d’être réexaminé" - - mail(from: NO_REPLY_EMAIL, to: dossier.user_email_for(:notification), subject: subject) do |format| - format.html { render layout: 'mailers/notifications_layout' } + mail(to: dossier.user_email_for(:notification), subject: @subject) do |format| + format.html { render layout: 'mailers/notifications_layout' } + end end end def notify_brouillon_near_deletion(dossiers, to_email) - @subject = default_i18n_subject(count: dossiers.count) - @dossiers = dossiers + I18n.with_locale(dossiers.first.user_locale) do + @subject = default_i18n_subject(count: dossiers.count) + @dossiers = dossiers - mail(to: to_email, subject: @subject) + mail(to: to_email, subject: @subject) + end end def notify_brouillon_deletion(dossier_hashes, to_email) @@ -70,24 +82,21 @@ class DossierMailer < ApplicationMailer end def notify_deletion_to_user(deleted_dossier, to_email) - @subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id) - @deleted_dossier = deleted_dossier + I18n.with_locale(deleted_dossier.user_locale) do + @subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id) + @deleted_dossier = deleted_dossier - mail(to: to_email, subject: @subject) + mail(to: to_email, subject: @subject) + end end def notify_instructeur_deletion_to_user(deleted_dossier, to_email) - @subject = default_i18n_subject(libelle_demarche: deleted_dossier.procedure.libelle) - @deleted_dossier = deleted_dossier + 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 - - def notify_instructeur(deleted_dossier, to_email) - @subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id) - @deleted_dossier = deleted_dossier - - mail(to: to_email, subject: @subject) + mail(to: to_email, subject: @subject) + end end def notify_deletion_to_administration(deleted_dossier, to_email) @@ -98,11 +107,13 @@ class DossierMailer < ApplicationMailer end def notify_automatic_deletion_to_user(deleted_dossiers, to_email) - @state = deleted_dossiers.first.state - @subject = default_i18n_subject(count: deleted_dossiers.count) - @deleted_dossiers = deleted_dossiers + I18n.with_locale(deleted_dossiers.first.user_locale) do + @state = deleted_dossiers.first.state + @subject = default_i18n_subject(count: deleted_dossiers.count) + @deleted_dossiers = deleted_dossiers - mail(to: to_email, subject: @subject) + mail(to: to_email, subject: @subject) + end end def notify_automatic_deletion_to_administration(deleted_dossiers, to_email) @@ -113,11 +124,13 @@ class DossierMailer < ApplicationMailer end def notify_near_deletion_to_user(dossiers, to_email) - @state = dossiers.first.state - @subject = default_i18n_subject(count: dossiers.count, state: @state) - @dossiers = dossiers + I18n.with_locale(dossiers.first.user_locale) do + @state = dossiers.first.state + @subject = default_i18n_subject(count: dossiers.count, state: @state) + @dossiers = dossiers - mail(to: to_email, subject: @subject) + mail(to: to_email, subject: @subject) + end end def notify_near_deletion_to_administration(dossiers, to_email) @@ -129,18 +142,19 @@ class DossierMailer < ApplicationMailer end def notify_groupe_instructeur_changed(instructeur, dossier) - @subject = "Un dossier a changé de groupe instructeur" - @dossier_id = dossier.id - @demarche = dossier.procedure.libelle + @subject = default_i18n_subject(dossier_id: dossier.id) + @dossier = dossier - mail(from: NO_REPLY_EMAIL, to: instructeur.email, subject: @subject) + mail(to: instructeur.email, subject: @subject) end def notify_brouillon_not_submitted(dossier) - @subject = "Attention : votre dossier n’est pas déposé." - @dossier = dossier + I18n.with_locale(dossier.user_locale) do + @subject = default_i18n_subject(dossier_id: dossier.id) + @dossier = dossier - mail(to: dossier.user_email_for(:notification), subject: @subject) + mail(to: dossier.user_email_for(:notification), subject: @subject) + end end protected diff --git a/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml b/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml index c45087d0f..55eab2566 100644 --- a/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml +++ b/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml @@ -3,7 +3,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - = "Vous suiviez jusqu'à maintenant le dossier n°#{@dossier_id} de la démarche #{@demarche}." + = "Vous suiviez jusqu'à maintenant le dossier n° #{@dossier.id} de la démarche #{@dossier.procedure.libelle}." L’usager a modifié le groupe de routage. Son dossier appartient maintenant à un groupe instructeur dont vous ne faites pas partie. %p Suite à cette modification, vous ne suivez plus ce dossier. diff --git a/app/views/dossier_mailer/notify_new_answer.en.html.haml b/app/views/dossier_mailer/notify_new_answer.en.html.haml deleted file mode 100644 index 88ef43b79..000000000 --- a/app/views/dossier_mailer/notify_new_answer.en.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -- content_for :procedure_logo do - = render 'layouts/mailers/logo', url: @logo_url - -%p= t(:hello, scope: [:views, :shared, :greetings]) - -- if !@dossier.brouillon? - %p - You received - %strong a new message - from the service in charge of examine your File. - %p - To read the message and answer it, select the following link: - - = round_button('Read the message', messagerie_dossier_url(@dossier), :primary) -- else - %p - You received - %strong a new message - from the service in charge of examine the File you started a draft for on the procedure #{@dossier.procedure.libelle}. - %p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" } - = @body - - %p - If you chose to contact the service, please use the email available below in the page. - - = round_button('Open the File', dossier_url(@dossier), :primary) - -= render 'layouts/mailers/signature', service: @service - -- content_for :footer do - = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 932b6e4f1..28f26ca6f 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -4,25 +4,15 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) - if !@dossier.brouillon? - %p - Vous avez reçu un - %strong nouveau message - de la part du service en charge de votre dossier. - %p - Pour consulter le message et y répondre, cliquez sur le bouton ci-dessous : - - = round_button('Lire le message', messagerie_dossier_url(@dossier), :primary) + %p= t('.body', libelle_demarche: @dossier.procedure.libelle) + %p= t('.link') + = round_button(t('.access_message'), messagerie_dossier_url(@dossier), :primary) - else - %p - Vous avez reçu un - %strong nouveau message - du service pour lequel votre dossier est en brouillon pour la démarche #{@dossier.procedure.libelle}. + %p= t('.body_draft', libelle_demarche: @dossier.procedure.libelle) %p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" } = @body - - %p Si vous souhaitez contacter le service, merci de le faire directement à l'aide de l'email en bas de page. - - = round_button('Voir le dossier', dossier_url(@dossier), :primary) + %p= t('.contact') + = round_button(t('.access_file'), dossier_url(@dossier), :primary) = render 'layouts/mailers/signature', service: @service diff --git a/app/views/dossier_mailer/notify_new_draft.en.html.haml b/app/views/dossier_mailer/notify_new_draft.en.html.haml deleted file mode 100644 index 2c6e001b3..000000000 --- a/app/views/dossier_mailer/notify_new_draft.en.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :procedure_logo do - = render 'layouts/mailers/logo', url: @logo_url - -%p= t(:hello, scope: [:views, :shared, :greetings]) - -%p - You started filling a File on the procedure: - = succeed '.' do - %strong « #{@dossier.procedure.libelle} » - -%p - You can access your File, to review or complete, by clicking on the following button: - -= round_button('Access your File', dossier_url(@dossier), :primary) - -- if @dossier.procedure.auto_archive_on - %p - Your File needs to be submitted before #{procedure_auto_archive_datetime(@dossier.procedure)}. - -= render 'layouts/mailers/signature' - -- content_for :footer do - = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index fdb341967..ee0219970 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -3,21 +3,12 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) -%p - Vous avez commencé à remplir un dossier pour la démarche - = succeed '.' do - %strong « #{@dossier.procedure.libelle} » - -%p - Vous pouvez - %strong retrouver et compléter votre dossier - en cliquant sur le bouton ci-dessous: - -= round_button('Afficher votre dossier', dossier_url(@dossier), :primary) +%p= t('.body', libelle_demarche: @dossier.procedure.libelle) +%p= t('.link') += round_button(t('.access_file'), dossier_url(@dossier), :primary) - if @dossier.procedure.auto_archive_on - %p - Vous pouvez déposer votre dossier jusqu’au #{procedure_auto_archive_datetime(@dossier.procedure)}. + %p= t('.submit_before', before: procedure_auto_archive_datetime(@dossier.procedure)) = render 'layouts/mailers/signature' diff --git a/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml b/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml deleted file mode 100644 index 2f64e85ae..000000000 --- a/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -- content_for :procedure_logo do - = render 'layouts/mailers/logo', url: @logo_url - -%p= t(:hello, scope: [:views, :shared, :greetings]) - -%p - Your File will be reexamined. All previous decisions are void. - To see the File created on procedure - %strong= @dossier.procedure.libelle - , select the following link: - = link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener' - -- if @dossier.procedure.service.present? - %p - In order to get more details about the decision to reexamin, please contact the following service: - = mail_to @dossier.procedure.service.email, @dossier.procedure.service.email - -= render 'layouts/mailers/signature' - -- content_for :footer do - = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_revert_to_instruction.html.haml b/app/views/dossier_mailer/notify_revert_to_instruction.html.haml index 0f75d8070..e8323b95c 100644 --- a/app/views/dossier_mailer/notify_revert_to_instruction.html.haml +++ b/app/views/dossier_mailer/notify_revert_to_instruction.html.haml @@ -4,15 +4,11 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - Votre dossier va être réexaminé, la précédente décision sur ce dossier est caduque. - Vous pouvez retrouver le dossier que vous avez créé pour la démarche - %strong= @dossier.procedure.libelle - à l'adresse suivante : + = t('.body', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle) = link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener' - if @dossier.procedure.service.present? %p - Pour obtenir le détail de cette modification de la décision, vous pouvez contacter par - email: + = t('.contact') = mail_to @dossier.procedure.service.email, @dossier.procedure.service.email = render 'layouts/mailers/signature' diff --git a/config/locales/views/dossier_mailer/notify_brouillon_not_submitted/fr.yml b/config/locales/views/dossier_mailer/notify_brouillon_not_submitted/fr.yml new file mode 100644 index 000000000..78ee3eae0 --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_brouillon_not_submitted/fr.yml @@ -0,0 +1,4 @@ +fr: + dossier_mailer: + notify_brouillon_not_submitted: + subject: "Attention : votre dossier nº %{dossier_id} n’est pas déposé" diff --git a/config/locales/views/dossier_mailer/notify_groupe_instructeur_changed/fr.yml b/config/locales/views/dossier_mailer/notify_groupe_instructeur_changed/fr.yml new file mode 100644 index 000000000..541d2607d --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_groupe_instructeur_changed/fr.yml @@ -0,0 +1,4 @@ +fr: + dossier_mailer: + notify_groupe_instructeur_changed: + subject: Le dossier nº %{dossier_id} a changé de groupe instructeur diff --git a/config/locales/views/dossier_mailer/notify_new_answer/en.yml b/config/locales/views/dossier_mailer/notify_new_answer/en.yml new file mode 100644 index 000000000..5184b1c71 --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_new_answer/en.yml @@ -0,0 +1,13 @@ +fr: + dossier_mailer: + notify_new_answer: + subject: New message on your file nº %{dossier_id} « %{libelle_demarche} » + body_html: | + You received a new message from the service in charge of reviewing your file on « %{libelle_demarche} ». + link: | + To read the message and answer it, select the following link: + body_draft_html: | + You received a new message from the service in charge of reviewing the file you started a draft for on the procedure « %{libelle_demarche} ». + contact: If you chose to contact the service, please use the email available below in the page. + access_message: Read the message + access_file: Open file diff --git a/config/locales/views/dossier_mailer/notify_new_answer/fr.yml b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml new file mode 100644 index 000000000..334ed7fad --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml @@ -0,0 +1,13 @@ +fr: + dossier_mailer: + notify_new_answer: + subject: Nouveau message pour votre dossier nº %{dossier_id} « %{libelle_demarche} » + body_html: | + Vous avez reçu un nouveau message de la part du service en charge de votre dossier. + link: | + Pour consulter le message et y répondre, cliquez sur le bouton ci-dessous : + body_draft_html: | + Vous avez reçu un nouveau messagedu service pour lequel votre dossier est en brouillon pour la démarche « %{libelle_demarche} ». + contact: Si vous souhaitez contacter le service, merci de le faire directement à l'aide de l'email en bas de page. + access_message: Lire le message + access_file: Voir le dossier diff --git a/config/locales/views/dossier_mailer/notify_new_dossier_depose_to_instructeur/fr.yml b/config/locales/views/dossier_mailer/notify_new_dossier_depose_to_instructeur/fr.yml index 736475042..967ae13eb 100644 --- a/config/locales/views/dossier_mailer/notify_new_dossier_depose_to_instructeur/fr.yml +++ b/config/locales/views/dossier_mailer/notify_new_dossier_depose_to_instructeur/fr.yml @@ -1,5 +1,5 @@ fr: dossier_mailer: notify_new_dossier_depose_to_instructeur: - subject: Nouveau dossier déposé pour la démarche %{libelle_demarche} - body: Un nouveau dossier a été déposé (n° %{dossier_id}) pour la démarche %{libelle_demarche} + subject: Nouveau dossier déposé pour la démarche « %{libelle_demarche} » + body: Un nouveau dossier a été déposé (n° %{dossier_id}) pour la démarche « %{libelle_demarche} » diff --git a/config/locales/views/dossier_mailer/notify_new_draft/en.yml b/config/locales/views/dossier_mailer/notify_new_draft/en.yml new file mode 100644 index 000000000..95c3f766a --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_new_draft/en.yml @@ -0,0 +1,10 @@ +en: + dossier_mailer: + notify_new_draft: + subject: Draft file created on procedure « %{libelle_demarche} » + body_html: | + You created a draft file on procedure « %{libelle_demarche} ». + link_html: | + You can access your file, to review or complete, by clicking on the following button: + submit_before: Your file needs to be submitted before %{before} + access_file: Open file diff --git a/config/locales/views/dossier_mailer/notify_new_draft/fr.yml b/config/locales/views/dossier_mailer/notify_new_draft/fr.yml new file mode 100644 index 000000000..6fc4bad51 --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_new_draft/fr.yml @@ -0,0 +1,10 @@ +fr: + dossier_mailer: + notify_new_draft: + subject: Retrouvez votre brouillon pour la démarche « %{libelle_demarche} » + body_html: | + Vous avez commencé à remplir un dossier pour la démarche « %{libelle_demarche} ». + link_html: | + Vous pouvez retrouver et compléter votre dossier en cliquant sur le bouton ci-dessous : + submit_before: Vous pouvez déposer votre dossier jusqu’au %{before}. + access_file: Afficher votre dossier diff --git a/config/locales/views/dossier_mailer/notify_revert_to_instruction/en.yml b/config/locales/views/dossier_mailer/notify_revert_to_instruction/en.yml new file mode 100644 index 000000000..6f820beeb --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_revert_to_instruction/en.yml @@ -0,0 +1,9 @@ +en: + dossier_mailer: + notify_revert_to_instruction: + subject: Your file nº %{dossier_id} « %{libelle_demarche} » will be reexamined + body_html: | + Your file nº %{dossier_id} will be reexamined. All previous decisions are void. + To see the file created on procedure « %{libelle_demarche} », select the following link: + contact: | + In order to get more details about the decision to reexamin, please contact the following service: diff --git a/config/locales/views/dossier_mailer/notify_revert_to_instruction/fr.yml b/config/locales/views/dossier_mailer/notify_revert_to_instruction/fr.yml new file mode 100644 index 000000000..bf26477c2 --- /dev/null +++ b/config/locales/views/dossier_mailer/notify_revert_to_instruction/fr.yml @@ -0,0 +1,9 @@ +fr: + dossier_mailer: + notify_revert_to_instruction: + subject: Votre dossier nº %{dossier_id} sur la démarche « %{libelle_demarche} » est en train d’être réexaminé + body_html: | + Votre dossier va être réexaminé, la précédente décision sur ce dossier est caduque. + Vous pouvez retrouver le dossier que vous avez créé pour la démarche « %{libelle_demarche} » à l'adresse suivante : + contact: | + Pour obtenir le détail de cette modification de la décision, vous pouvez contacter par email : diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index e68a073ee..dccd67abb 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -202,8 +202,8 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_groupe_instructeur_changed(instructeur, dossier) } - it { expect(subject.subject).to eq("Un dossier a changé de groupe instructeur") } - it { expect(subject.body).to include("n°#{dossier.id}") } + it { expect(subject.subject).to eq("Le dossier nº #{dossier.id} a changé de groupe instructeur") } + it { expect(subject.body).to include("n° #{dossier.id}") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("Suite à cette modification, vous ne suivez plus ce dossier.") } end