[Emails] Améliore les emails de nouveau brouillon et de nouveau… (#4112)
Usager : améliore les emails de nouveau brouillon et de nouveau message
This commit is contained in:
commit
d6b767a82d
9 changed files with 71 additions and 29 deletions
5
app/helpers/mailer_helper.rb
Normal file
5
app/helpers/mailer_helper.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module MailerHelper
|
||||||
|
def round_button(text, url)
|
||||||
|
render 'shared/mailer_round_button', text: text, url: url
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,4 +2,22 @@ class ApplicationMailer < ActionMailer::Base
|
||||||
helper :application # gives access to all helpers defined within `application_helper`.
|
helper :application # gives access to all helpers defined within `application_helper`.
|
||||||
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
|
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
|
# Attach the procedure logo to the email (if any).
|
||||||
|
# Returns the attachment url.
|
||||||
|
def attach_logo(procedure)
|
||||||
|
return nil if !procedure.logo?
|
||||||
|
|
||||||
|
begin
|
||||||
|
logo_filename = procedure.logo.filename
|
||||||
|
attachments.inline[logo_filename] = procedure.logo.read
|
||||||
|
attachments[logo_filename].url
|
||||||
|
|
||||||
|
rescue StandardError => e
|
||||||
|
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
|
||||||
|
Raven.extra_context(procedure_id: procedure.id)
|
||||||
|
Raven.capture_exception(e)
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
# Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer
|
# Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer
|
||||||
class DossierMailer < ApplicationMailer
|
class DossierMailer < ApplicationMailer
|
||||||
|
helper ServiceHelper
|
||||||
|
helper MailerHelper
|
||||||
|
|
||||||
layout 'mailers/layout'
|
layout 'mailers/layout'
|
||||||
|
|
||||||
def notify_new_draft(dossier)
|
def notify_new_draft(dossier)
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
|
@service = dossier.procedure.service
|
||||||
|
@logo_url = attach_logo(dossier.procedure)
|
||||||
|
|
||||||
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
|
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
|
||||||
|
|
||||||
mail(to: dossier.user.email, subject: subject)
|
mail(to: dossier.user.email, subject: subject) do |format|
|
||||||
|
format.html { render layout: 'mailers/notification' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_new_answer(dossier)
|
def notify_new_answer(dossier)
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
|
@service = dossier.procedure.service
|
||||||
|
@logo_url = attach_logo(dossier.procedure)
|
||||||
|
|
||||||
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
|
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
|
||||||
|
|
||||||
mail(to: dossier.user.email, subject: subject) do |format|
|
mail(to: dossier.user.email, subject: subject) do |format|
|
||||||
|
|
|
@ -38,20 +38,9 @@ class NotificationMailer < ApplicationMailer
|
||||||
|
|
||||||
create_commentaire_for_notification(dossier, subject, body)
|
create_commentaire_for_notification(dossier, subject, body)
|
||||||
|
|
||||||
if dossier.procedure.logo?
|
|
||||||
begin
|
|
||||||
logo_filename = dossier.procedure.logo.filename
|
|
||||||
attachments.inline[logo_filename] = dossier.procedure.logo.read
|
|
||||||
@logo_url = attachments[logo_filename].url
|
|
||||||
rescue StandardError => e
|
|
||||||
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
|
|
||||||
Raven.extra_context(procedure_id: dossier.procedure.id)
|
|
||||||
Raven.capture_exception(e)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
@service = dossier.procedure.service
|
@service = dossier.procedure.service
|
||||||
|
@logo_url = attach_logo(dossier.procedure)
|
||||||
|
|
||||||
mail(subject: subject, to: email) do |format|
|
mail(subject: subject, to: email) do |format|
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Bonjour,
|
Bonjour,
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Un nouveau message est disponible dans votre espace demarches-simplifiees.fr.
|
L’administration en charge de votre dossier vous a
|
||||||
|
%strong envoyé un nouveau message.
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Pour le consulter, merci de vous rendre sur
|
Pour le consulter et y répondre, cliquez sur le bouton ci-dessous :
|
||||||
= link_to messagerie_dossier_url(@dossier), messagerie_dossier_url(@dossier), target: '_blank', rel:'noopener'
|
|
||||||
|
|
||||||
= render partial: "layouts/mailers/signature"
|
= round_button('Lire le message', messagerie_dossier_url(@dossier))
|
||||||
|
|
||||||
|
= render partial: "layouts/mailers/signature", locals: { service: @service }
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
Bonjour,
|
Bonjour,
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Vous pouvez retrouver et compléter le brouillon que vous avez créé pour la démarche
|
Vous avez commencé à remplir un dossier pour la démarche « #{@dossier.procedure.libelle} ».
|
||||||
%strong= @dossier.procedure.libelle
|
|
||||||
à l'adresse suivante :
|
%p
|
||||||
|
Vous pouvez
|
||||||
|
%strong retrouver et compléter votre dossier
|
||||||
|
à l’adresse suivante :
|
||||||
= link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
= link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||||
|
|
||||||
= render partial: "layouts/mailers/signature"
|
= render partial: "layouts/mailers/signature"
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
%p
|
%p
|
||||||
Bonne journée,
|
Bonne journée,
|
||||||
%br
|
%br
|
||||||
L’équipe demarches-simplifiees.fr
|
- if defined?(service) && service && service.nom.present?
|
||||||
|
= service.nom
|
||||||
|
- else
|
||||||
|
L’équipe demarches-simplifiees.fr
|
||||||
|
|
|
@ -6,14 +6,12 @@
|
||||||
= image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
|
= image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
|
||||||
|
|
||||||
- content_for :footer do
|
- content_for :footer do
|
||||||
- if @dossier.present?
|
|
||||||
- messagerie_url = messagerie_dossier_url(@dossier)
|
|
||||||
- else
|
|
||||||
- messagerie_url = "#"
|
|
||||||
%strong
|
%strong
|
||||||
Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre
|
Merci de ne pas répondre à cet email.
|
||||||
= succeed '.' do
|
- if @dossier.present? && @dossier.messagerie_available?
|
||||||
= link_to 'messagerie', messagerie_url, target: '_blank', rel: 'noopener'
|
Pour vous adresser à votre administration, passez directement par la
|
||||||
|
= succeed '.' do
|
||||||
|
= link_to 'messagerie du dossier', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||||
|
|
||||||
- if @service.present?
|
- if @service.present?
|
||||||
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
|
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
|
||||||
|
@ -31,7 +29,11 @@
|
||||||
%p
|
%p
|
||||||
%strong Poser une question sur votre dossier :
|
%strong Poser une question sur votre dossier :
|
||||||
%br
|
%br
|
||||||
= link_to 'Par la messagerie', messagerie_url, target: '_blank', rel: 'noopener'
|
- if @dossier.present? && @dossier.messagerie_available?
|
||||||
|
= link_to 'Par la messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||||
|
- else
|
||||||
|
Par email :
|
||||||
|
= link_to @service.email, "mailto:#{@service.email}"
|
||||||
%br
|
%br
|
||||||
Par téléphone :
|
Par téléphone :
|
||||||
= link_to @service.telephone, "tel:#{@service.telephone}"
|
= link_to @service.telephone, "tel:#{@service.telephone}"
|
||||||
|
|
9
app/views/shared/_mailer_round_button.html.haml
Normal file
9
app/views/shared/_mailer_round_button.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/# From https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design
|
||||||
|
%table{ width: "100%", border: "0", cellspacing:"0", cellpadding:"0" }
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%table{ border:"0", cellspacing:"0", cellpadding:"0", style:"margin: auto" }
|
||||||
|
%tr
|
||||||
|
%td{ align:"center", style:"border-radius: 5px;", bgcolor:"#0069cc" }
|
||||||
|
%a{ href: url, target:"_blank", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #0069cc; display: inline-block;" }
|
||||||
|
= text
|
Loading…
Reference in a new issue