From b571f0706c681a66fb0afc106af2d21e5098f31f Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 31 May 2018 18:32:13 +0200 Subject: [PATCH 1/7] [Fix #2015] Make sur all data is initialised for index view --- app/controllers/admin/procedures_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 6d8a3cd9e..3e4d5a2b7 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -164,8 +164,8 @@ class Admin::ProceduresController < AdminController flash.alert = new_procedure.errors.full_messages redirect_to new_from_existing_admin_procedures_path else - flash.now.alert = new_procedure.errors.full_messages - render 'index' + flash.alert = new_procedure.errors.full_messages + redirect_to admin_procedures_path end end From a60f1c434ebbfa1ce49ba4a5f1060a29ec451ed5 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 23:58:10 +0200 Subject: [PATCH 2/7] Improve the mailers readability --- app/mailers/administrateur_mailer.rb | 1 + app/mailers/administration_mailer.rb | 2 ++ app/mailers/avis_mailer.rb | 1 + app/mailers/dossier_mailer.rb | 2 ++ app/mailers/gestionnaire_mailer.rb | 2 ++ app/mailers/user_mailer.rb | 1 + 6 files changed, 9 insertions(+) diff --git a/app/mailers/administrateur_mailer.rb b/app/mailers/administrateur_mailer.rb index a46e46658..7f2c647da 100644 --- a/app/mailers/administrateur_mailer.rb +++ b/app/mailers/administrateur_mailer.rb @@ -5,6 +5,7 @@ class AdministrateurMailer < ApplicationMailer @administrateur = administrateur @reset_password_token = reset_password_token @expiration_date = @administrateur.reset_password_sent_at + Devise.reset_password_within + mail(to: administrateur.email, subject: "demarches-simplifiees.fr - N'oubliez pas d'activer votre compte administrateur", reply_to: "contact@demarches-simplifiees.fr") diff --git a/app/mailers/administration_mailer.rb b/app/mailers/administration_mailer.rb index b13081cb7..c9a584de5 100644 --- a/app/mailers/administration_mailer.rb +++ b/app/mailers/administration_mailer.rb @@ -12,6 +12,7 @@ class AdministrationMailer < ApplicationMailer def invite_admin(admin, reset_password_token) @reset_password_token = reset_password_token @admin = admin + mail(to: admin.email, subject: "demarches-simplifiees.fr - Activez votre compte administrateur", reply_to: "contact@demarches-simplifiees.fr") @@ -25,6 +26,7 @@ class AdministrationMailer < ApplicationMailer def dubious_procedures(procedures_and_type_de_champs) @procedures_and_type_de_champs = procedures_and_type_de_champs + mail(to: 'equipe@demarches-simplifiees.fr', subject: "[RGS] De nouvelles procédures comportent des champs interdits") end diff --git a/app/mailers/avis_mailer.rb b/app/mailers/avis_mailer.rb index 52c826b02..2fd8401f4 100644 --- a/app/mailers/avis_mailer.rb +++ b/app/mailers/avis_mailer.rb @@ -2,6 +2,7 @@ class AvisMailer < ApplicationMailer def avis_invitation(avis) @avis = avis email = @avis.gestionnaire&.email || @avis.email + mail(to: email, subject: "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})") end end diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 1d8643314..10fd85a14 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -3,11 +3,13 @@ class DossierMailer < ApplicationMailer def notify_deletion_to_user(deleted_dossier, to_email) @deleted_dossier = deleted_dossier + mail(to: to_email, subject: "Votre dossier n° #{@deleted_dossier.dossier_id} a bien été supprimé") end def notify_deletion_to_administration(deleted_dossier, to_email) @deleted_dossier = deleted_dossier + mail(to: to_email, subject: "Le dossier n° #{@deleted_dossier.dossier_id} a été supprimé à la demande de l'usager") end end diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index fbb090012..bc9782ee6 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -4,6 +4,7 @@ class GestionnaireMailer < ApplicationMailer def invite_gestionnaire(gestionnaire, reset_password_token) @reset_password_token = reset_password_token @gestionnaire = gestionnaire + mail(to: gestionnaire.email, subject: "demarches-simplifiees.fr - Activez votre compte accompagnateur", reply_to: "contact@demarches-simplifiees.fr") @@ -16,6 +17,7 @@ class GestionnaireMailer < ApplicationMailer def last_week_overview(gestionnaire) headers['X-mailjet-campaign'] = 'last_week_overview' overview = gestionnaire.last_week_overview + send_mail gestionnaire.email, overview, 'Vos activités sur demarches-simplifiees.fr' end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 2bef4f3ba..fde3369a9 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -3,6 +3,7 @@ class UserMailer < ApplicationMailer def new_account_warning(user) @user = user + mail(to: user.email, subject: "Création de compte") end end From 8eeb10bc5c707cb5672abc1c41bc8d99140987c8 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 15:26:07 +0200 Subject: [PATCH 3/7] Add parentheses --- app/mailers/gestionnaire_mailer.rb | 2 +- app/mailers/invite_mailer.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index bc9782ee6..7410192ff 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -18,7 +18,7 @@ class GestionnaireMailer < ApplicationMailer headers['X-mailjet-campaign'] = 'last_week_overview' overview = gestionnaire.last_week_overview - send_mail gestionnaire.email, overview, 'Vos activités sur demarches-simplifiees.fr' + send_mail(gestionnaire.email, overview, 'Vos activités sur demarches-simplifiees.fr') end def send_dossier(sender, dossier, recipient) diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb index 48c326464..220235fcd 100644 --- a/app/mailers/invite_mailer.rb +++ b/app/mailers/invite_mailer.rb @@ -1,14 +1,14 @@ class InviteMailer < ApplicationMailer def invite_user(invite) - vars_mailer invite + vars_mailer(invite) - send_mail invite.email, "demarches-simplifiees.fr - Participez à l'élaboration d'un dossier", invite.email_sender if invite.user.present? + send_mail(invite.email, "demarches-simplifiees.fr - Participez à l'élaboration d'un dossier", invite.email_sender) if invite.user.present? end def invite_guest(invite) - vars_mailer invite + vars_mailer(invite) - send_mail invite.email, "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur demarches-simplifiees.fr", invite.email_sender + send_mail(invite.email, "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur demarches-simplifiees.fr", invite.email_sender) end private From a3f5ae9d0b1383d72636bbdd2d863c3ad2c76379 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 15:26:02 +0200 Subject: [PATCH 4/7] Add a variable to improve readability --- app/mailers/administrateur_mailer.rb | 3 ++- app/mailers/administration_mailer.rb | 13 +++++++++---- app/mailers/avis_mailer.rb | 3 ++- app/mailers/dossier_mailer.rb | 6 ++++-- app/mailers/gestionnaire_mailer.rb | 10 +++++++--- app/mailers/invite_mailer.rb | 6 ++++-- app/mailers/user_mailer.rb | 3 ++- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/mailers/administrateur_mailer.rb b/app/mailers/administrateur_mailer.rb index 7f2c647da..91d289672 100644 --- a/app/mailers/administrateur_mailer.rb +++ b/app/mailers/administrateur_mailer.rb @@ -5,9 +5,10 @@ class AdministrateurMailer < ApplicationMailer @administrateur = administrateur @reset_password_token = reset_password_token @expiration_date = @administrateur.reset_password_sent_at + Devise.reset_password_within + subject = "demarches-simplifiees.fr - N'oubliez pas d'activer votre compte administrateur" mail(to: administrateur.email, - subject: "demarches-simplifiees.fr - N'oubliez pas d'activer votre compte administrateur", + subject: subject, reply_to: "contact@demarches-simplifiees.fr") end end diff --git a/app/mailers/administration_mailer.rb b/app/mailers/administration_mailer.rb index c9a584de5..1f2b222ea 100644 --- a/app/mailers/administration_mailer.rb +++ b/app/mailers/administration_mailer.rb @@ -4,30 +4,35 @@ class AdministrationMailer < ApplicationMailer def new_admin_email(admin, administration) @admin = admin @administration = administration + subject = "Création d'un compte Admin demarches-simplifiees.fr" mail(to: 'tech@demarches-simplifiees.fr', - subject: "Création d'un compte Admin demarches-simplifiees.fr") + subject: subject) end def invite_admin(admin, reset_password_token) @reset_password_token = reset_password_token @admin = admin + subject = "demarches-simplifiees.fr - Activez votre compte administrateur" mail(to: admin.email, - subject: "demarches-simplifiees.fr - Activez votre compte administrateur", + subject: subject, reply_to: "contact@demarches-simplifiees.fr") end def refuse_admin(admin_email) + subject = "demarches-simplifiees.fr - Votre demande de compte a été refusée" + mail(to: admin_email, - subject: "demarches-simplifiees.fr - Votre demande de compte a été refusée", + subject: subject, reply_to: "contact@demarches-simplifiees.fr") end def dubious_procedures(procedures_and_type_de_champs) @procedures_and_type_de_champs = procedures_and_type_de_champs + subject = "[RGS] De nouvelles procédures comportent des champs interdits" mail(to: 'equipe@demarches-simplifiees.fr', - subject: "[RGS] De nouvelles procédures comportent des champs interdits") + subject: subject) end end diff --git a/app/mailers/avis_mailer.rb b/app/mailers/avis_mailer.rb index 2fd8401f4..2580f4be6 100644 --- a/app/mailers/avis_mailer.rb +++ b/app/mailers/avis_mailer.rb @@ -2,7 +2,8 @@ class AvisMailer < ApplicationMailer def avis_invitation(avis) @avis = avis email = @avis.gestionnaire&.email || @avis.email + subject = "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})" - mail(to: email, subject: "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})") + mail(to: email, subject: subject) end end diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 10fd85a14..96e2b46b0 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -3,13 +3,15 @@ class DossierMailer < ApplicationMailer def notify_deletion_to_user(deleted_dossier, to_email) @deleted_dossier = deleted_dossier + subject = "Votre dossier n° #{@deleted_dossier.dossier_id} a bien été supprimé" - mail(to: to_email, subject: "Votre dossier n° #{@deleted_dossier.dossier_id} a bien été supprimé") + mail(to: to_email, subject: subject) end def notify_deletion_to_administration(deleted_dossier, to_email) @deleted_dossier = deleted_dossier + subject = "Le dossier n° #{@deleted_dossier.dossier_id} a été supprimé à la demande de l'usager" - mail(to: to_email, subject: "Le dossier n° #{@deleted_dossier.dossier_id} a été supprimé à la demande de l'usager") + mail(to: to_email, subject: subject) end end diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index 7410192ff..c3e3edc6a 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -4,21 +4,25 @@ class GestionnaireMailer < ApplicationMailer def invite_gestionnaire(gestionnaire, reset_password_token) @reset_password_token = reset_password_token @gestionnaire = gestionnaire + subject = "demarches-simplifiees.fr - Activez votre compte accompagnateur" mail(to: gestionnaire.email, - subject: "demarches-simplifiees.fr - Activez votre compte accompagnateur", + subject: subject, reply_to: "contact@demarches-simplifiees.fr") end def user_to_gestionnaire(email) - send_mail(email, nil, "Vous avez été nommé accompagnateur sur demarches-simplifiees.fr") + subject = "Vous avez été nommé accompagnateur sur demarches-simplifiees.fr" + + send_mail(email, nil, subject) end def last_week_overview(gestionnaire) headers['X-mailjet-campaign'] = 'last_week_overview' overview = gestionnaire.last_week_overview + subject = 'Vos activités sur demarches-simplifiees.fr' - send_mail(gestionnaire.email, overview, 'Vos activités sur demarches-simplifiees.fr') + send_mail(gestionnaire.email, overview, subject) end def send_dossier(sender, dossier, recipient) diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb index 220235fcd..1b07d39ff 100644 --- a/app/mailers/invite_mailer.rb +++ b/app/mailers/invite_mailer.rb @@ -1,14 +1,16 @@ class InviteMailer < ApplicationMailer def invite_user(invite) vars_mailer(invite) + subject = "demarches-simplifiees.fr - Participez à l'élaboration d'un dossier" - send_mail(invite.email, "demarches-simplifiees.fr - Participez à l'élaboration d'un dossier", invite.email_sender) if invite.user.present? + send_mail(invite.email, subject, invite.email_sender) if invite.user.present? end def invite_guest(invite) vars_mailer(invite) + subject = "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur demarches-simplifiees.fr" - send_mail(invite.email, "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur demarches-simplifiees.fr", invite.email_sender) + send_mail(invite.email, subject, invite.email_sender) end private diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index fde3369a9..2f1ae9873 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -3,7 +3,8 @@ class UserMailer < ApplicationMailer def new_account_warning(user) @user = user + subject = "Création de compte" - mail(to: user.email, subject: "Création de compte") + mail(to: user.email, subject: subject) end end From 185f08f63e7da103a8e0511e435394cedec87e54 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 15:43:57 +0200 Subject: [PATCH 5/7] Add constants for email addresses --- app/controllers/admin/procedures_controller.rb | 2 +- app/controllers/administrateurs/activate_controller.rb | 2 +- app/controllers/gestionnaires/activate_controller.rb | 2 +- app/mailers/administrateur_mailer.rb | 2 +- app/mailers/administration_mailer.rb | 8 ++++---- app/mailers/gestionnaire_mailer.rb | 2 +- app/models/gestionnaire.rb | 8 ++++---- app/views/accessibilite/index.html.haml | 2 +- app/views/layouts/_new_header.haml | 2 +- .../new_gestionnaire/shared/messages/_message.html.haml | 2 +- .../shared/messages/_message_icon.html.haml | 3 ++- .../shared/messages/_message_issuer.html.haml | 4 ++-- app/views/root/patron.html.haml | 2 +- config/initializers/devise.rb | 2 ++ config/initializers/emails.rb | 7 +++++++ lib/mailers/attestation_closed_mail_discrepancy_mailer.rb | 2 +- spec/models/commentaire_spec.rb | 2 +- spec/models/gestionnaire_spec.rb | 4 ++-- 18 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 config/initializers/emails.rb diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 3e4d5a2b7..962943af1 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -46,7 +46,7 @@ class Admin::ProceduresController < AdminController procedure = current_administrateur.procedures.find(params[:id]) procedure.hide! - flash.notice = "Procédure supprimée, en cas d'erreur contactez nous : contact@demarches-simplifiees.fr" + flash.notice = "Procédure supprimée, en cas d'erreur contactez nous : #{CONTACT_EMAIL}" redirect_to admin_procedures_draft_path end diff --git a/app/controllers/administrateurs/activate_controller.rb b/app/controllers/administrateurs/activate_controller.rb index 5049a67e7..2421035b2 100644 --- a/app/controllers/administrateurs/activate_controller.rb +++ b/app/controllers/administrateurs/activate_controller.rb @@ -5,7 +5,7 @@ class Administrateurs::ActivateController < ApplicationController @administrateur = Administrateur.find_inactive_by_token(params[:token]) if !@administrateur - flash.alert = "Le lien de validation d'administrateur a expiré, contactez-nous à contact@demarches-simplifiees.fr pour obtenir un nouveau lien." + flash.alert = "Le lien de validation d'administrateur a expiré, contactez-nous à #{CONTACT_EMAIL} pour obtenir un nouveau lien." redirect_to root_path end end diff --git a/app/controllers/gestionnaires/activate_controller.rb b/app/controllers/gestionnaires/activate_controller.rb index 5eac9f317..2fa1d0d39 100644 --- a/app/controllers/gestionnaires/activate_controller.rb +++ b/app/controllers/gestionnaires/activate_controller.rb @@ -5,7 +5,7 @@ class Gestionnaires::ActivateController < ApplicationController @gestionnaire = Gestionnaire.with_reset_password_token(params[:token]) if !@gestionnaire - flash.alert = "Le lien de validation du compte accompagnateur a expiré, contactez-nous à contact@demarches-simplifiees.fr pour obtenir un nouveau lien." + flash.alert = "Le lien de validation du compte accompagnateur a expiré, contactez-nous à #{CONTACT_EMAIL} pour obtenir un nouveau lien." redirect_to root_path end end diff --git a/app/mailers/administrateur_mailer.rb b/app/mailers/administrateur_mailer.rb index 91d289672..e102aaa1e 100644 --- a/app/mailers/administrateur_mailer.rb +++ b/app/mailers/administrateur_mailer.rb @@ -9,6 +9,6 @@ class AdministrateurMailer < ApplicationMailer mail(to: administrateur.email, subject: subject, - reply_to: "contact@demarches-simplifiees.fr") + reply_to: CONTACT_EMAIL) end end diff --git a/app/mailers/administration_mailer.rb b/app/mailers/administration_mailer.rb index 1f2b222ea..612087574 100644 --- a/app/mailers/administration_mailer.rb +++ b/app/mailers/administration_mailer.rb @@ -6,7 +6,7 @@ class AdministrationMailer < ApplicationMailer @administration = administration subject = "Création d'un compte Admin demarches-simplifiees.fr" - mail(to: 'tech@demarches-simplifiees.fr', + mail(to: TECH_EMAIL, subject: subject) end @@ -17,7 +17,7 @@ class AdministrationMailer < ApplicationMailer mail(to: admin.email, subject: subject, - reply_to: "contact@demarches-simplifiees.fr") + reply_to: CONTACT_EMAIL) end def refuse_admin(admin_email) @@ -25,14 +25,14 @@ class AdministrationMailer < ApplicationMailer mail(to: admin_email, subject: subject, - reply_to: "contact@demarches-simplifiees.fr") + reply_to: CONTACT_EMAIL) end def dubious_procedures(procedures_and_type_de_champs) @procedures_and_type_de_champs = procedures_and_type_de_champs subject = "[RGS] De nouvelles procédures comportent des champs interdits" - mail(to: 'equipe@demarches-simplifiees.fr', + mail(to: EQUIPE_EMAIL, subject: subject) end end diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index c3e3edc6a..c95cbe860 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -8,7 +8,7 @@ class GestionnaireMailer < ApplicationMailer mail(to: gestionnaire.email, subject: subject, - reply_to: "contact@demarches-simplifiees.fr") + reply_to: CONTACT_EMAIL) end def user_to_gestionnaire(email) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 76b737e9a..e7fef8d10 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -102,8 +102,8 @@ class Gestionnaire < ApplicationRecord messagerie = follow.messagerie_seen_at.present? && dossier.commentaires - .where.not(email: 'contact@tps.apientreprise.fr') - .where.not(email: 'contact@demarches-simplifiees.fr') + .where.not(email: OLD_CONTACT_EMAIL) + .where.not(email: CONTACT_EMAIL) .updated_since?(follow.messagerie_seen_at).any? annotations_hash(demande, annotations_privees, avis_notif, messagerie) @@ -208,8 +208,8 @@ class Gestionnaire < ApplicationRecord updated_messagerie = dossiers .joins(:commentaires) .where('commentaires.updated_at > follows.messagerie_seen_at') - .where.not(commentaires: { email: 'contact@tps.apientreprise.fr' }) - .where.not(commentaires: { email: 'contact@demarches-simplifiees.fr' }) + .where.not(commentaires: { email: OLD_CONTACT_EMAIL }) + .where.not(commentaires: { email: CONTACT_EMAIL }) [ updated_demandes, diff --git a/app/views/accessibilite/index.html.haml b/app/views/accessibilite/index.html.haml index bc13252f0..d56f539bc 100644 --- a/app/views/accessibilite/index.html.haml +++ b/app/views/accessibilite/index.html.haml @@ -9,7 +9,7 @@ %h2.new-h2 Signaler un dysfonctionnement %p.new-p - Si, malgré notre vigilance, vous rencontriez le moindre problème d’accessibilité sur notre site, n’hésitez pas à nous écrire à contact@demarches-simplifiees.fr. + = "Si, malgré notre vigilance, vous rencontriez le moindre problème d’accessibilité sur notre site, n’hésitez pas à nous écrire à #{CONTACT_EMAIL}." %h2.new-h2 Défenseur des droits %p.new-p diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index f19ab1d10..f865b5f9f 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -29,7 +29,7 @@ %br – par téléphone : 01 76 42 02 87 %br - – par email : contact@demarches-simplifiees.fr + = "– par email : #{CONTACT_EMAIL}" - if nav_bar_profile == :user %ul.header-tabs diff --git a/app/views/new_gestionnaire/shared/messages/_message.html.haml b/app/views/new_gestionnaire/shared/messages/_message.html.haml index 6f343f3a5..dd902856f 100644 --- a/app/views/new_gestionnaire/shared/messages/_message.html.haml +++ b/app/views/new_gestionnaire/shared/messages/_message.html.haml @@ -4,7 +4,7 @@ %h2 %span.mail = render partial: 'new_gestionnaire/shared/messages/message_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } - - if ![current_gestionnaire.email, commentaire.dossier.user.email, 'contact@tps.apientreprise.fr', 'contact@demarches-simplifiees.fr'].include?(commentaire.email) + - if ![current_gestionnaire.email, commentaire.dossier.user.email, OLD_CONTACT_EMAIL, CONTACT_EMAIL].include?(commentaire.email) %span.guest Invité %span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) } = I18n.l(commentaire.created_at.localtime, format: '%d/%m/%Y à %H:%M ') diff --git a/app/views/new_gestionnaire/shared/messages/_message_icon.html.haml b/app/views/new_gestionnaire/shared/messages/_message_icon.html.haml index 84548339d..dc19bd941 100644 --- a/app/views/new_gestionnaire/shared/messages/_message_icon.html.haml +++ b/app/views/new_gestionnaire/shared/messages/_message_icon.html.haml @@ -1,7 +1,8 @@ - case commentaire.email - when current_gestionnaire.email = image_tag('icons/account-circle.svg', class: 'person-icon') -- when 'contact@demarches-simplifiees.fr' +- when OLD_CONTACT_EMAIL +- when CONTACT_EMAIL = image_tag('icons/mail.svg', class: 'person-icon') - else = image_tag('icons/blue-person.svg', class: 'person-icon') diff --git a/app/views/new_gestionnaire/shared/messages/_message_issuer.html.haml b/app/views/new_gestionnaire/shared/messages/_message_issuer.html.haml index e37798e07..afba289e6 100644 --- a/app/views/new_gestionnaire/shared/messages/_message_issuer.html.haml +++ b/app/views/new_gestionnaire/shared/messages/_message_issuer.html.haml @@ -1,8 +1,8 @@ - case commentaire.email - when current_gestionnaire.email Vous -- when 'contact@tps.apientreprise.fr' -- when 'contact@demarches-simplifiees.fr' +- when OLD_CONTACT_EMAIL +- when CONTACT_EMAIL Email automatique - else = commentaire.email diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index c6802ab98..be81ce4d7 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -190,7 +190,7 @@ .icon.bubble.avis-icon .width-100 %h2.gestionnaire - contact@demarches-simplifiees.fr + = CONTACT_EMAIL %span.date Réponse donnée le 13/01/2012 %p Je donne un avis favorable diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 4c8fe8b17..1ac79d92e 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,3 +1,5 @@ +require_relative "emails" + # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| diff --git a/config/initializers/emails.rb b/config/initializers/emails.rb new file mode 100644 index 000000000..9d81d1719 --- /dev/null +++ b/config/initializers/emails.rb @@ -0,0 +1,7 @@ +if !defined?(CONTACT_EMAIL) + CONTACT_EMAIL = "contact@demarches-simplifiees.fr" + EQUIPE_EMAIL = "equipe@demarches-simplifiees.fr" + TECH_EMAIL = "tech@demarches-simplifiees.fr" + + OLD_CONTACT_EMAIL = "contact@tps.apientreprise.fr" +end diff --git a/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb b/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb index 6b34473bc..cf8e38026 100644 --- a/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb +++ b/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb @@ -35,7 +35,7 @@ module Mailers #{detail_procedures(procedures)} Pour toute question vous pouvez nous joindre par téléphone au 01 76 42 02 87 - ou sur l’adresse email contact@demarches-simplifiees.fr. + ou sur l’adresse email #{CONTACT_EMAIL}. -- \nL’équipe demarches-simplifiees.fr HEREDOC end diff --git a/spec/models/commentaire_spec.rb b/spec/models/commentaire_spec.rb index b9b090091..0c58a56bf 100644 --- a/spec/models/commentaire_spec.rb +++ b/spec/models/commentaire_spec.rb @@ -31,7 +31,7 @@ describe Commentaire do expect(commentaire).not_to receive(:notify_user) expect(commentaire).not_to receive(:notify_gestionnaires) - commentaire.email = "contact@demarches-simplifiees.fr" + commentaire.email = CONTACT_EMAIL commentaire.save end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 1ea1f2af5..667b913fb 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -246,7 +246,7 @@ describe Gestionnaire, type: :model do end context 'when there is a new commentaire issued by tps' do - before { create(:commentaire, dossier: dossier, email: 'contact@demarches-simplifiees.fr') } + before { create(:commentaire, dossier: dossier, email: CONTACT_EMAIL) } it { is_expected.to match({ demande: false, annotations_privees: false, avis: false, messagerie: false }) } end @@ -327,7 +327,7 @@ describe Gestionnaire, type: :model do end context 'when there is a new commentaire issued by tps' do - before { create(:commentaire, dossier: dossier, email: 'contact@demarches-simplifiees.fr') } + before { create(:commentaire, dossier: dossier, email: CONTACT_EMAIL) } it { is_expected.to match([]) } end From 23931a759180183f2158443c21ff94dfbf97a57a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 15:45:25 +0200 Subject: [PATCH 6/7] Remove the contact_email locale --- app/mailers/application_mailer.rb | 2 +- app/mailers/notification_mailer.rb | 2 +- app/models/commentaire.rb | 2 +- app/views/layouts/_footer.html.haml | 2 +- app/views/layouts/_new_footer.html.haml | 2 +- app/views/root/landing.html.haml | 2 +- config/initializers/devise.rb | 2 +- config/locales/dynamics/fr.yml | 1 - lib/tasks/2018_05_30_missed_ar_messages.rake | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 498633860..8700d4539 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "demarches-simplifiees.fr <#{I18n.t('dynamics.contact_email')}>" + default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>" layout 'mailer' end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index e01a681e4..6fc9d4dbd 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -54,7 +54,7 @@ class NotificationMailer < ApplicationMailer def create_commentaire_for_notification(dossier, subject, body) Commentaire.create( dossier: dossier, - email: I18n.t("dynamics.contact_email"), + email: CONTACT_EMAIL, body: ["[#{subject}]", body].join("

") ) end diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index be89d2ef8..e362fa8b0 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -36,7 +36,7 @@ class Commentaire < ApplicationRecord # - If a user or an invited user posted a commentaire, do nothing, # the notification system will properly # - Otherwise, a gestionnaire posted a commentaire, we need to notify the user - if !email.in?([I18n.t("dynamics.contact_email"), dossier_user_email, *invited_users_emails]) + if !email.in?([CONTACT_EMAIL, dossier_user_email, *invited_users_emails]) notify_user end end diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index d2ed0870a..1eae6f9ab 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -9,4 +9,4 @@ \- = link_to 'CGU / Mentions légales', CGU_URL \- - = link_to 'Contact', "mailto:"+t('dynamics.contact_email') + = link_to 'Contact', "mailto:#{CONTACT_EMAIL}" diff --git a/app/views/layouts/_new_footer.html.haml b/app/views/layouts/_new_footer.html.haml index 462609955..33ed6d2cc 100644 --- a/app/views/layouts/_new_footer.html.haml +++ b/app/views/layouts/_new_footer.html.haml @@ -30,7 +30,7 @@ %ul.footer-links %li.footer-link = link_to "Contact", - "mailto:#{t('dynamics.contact_email')}", + "mailto:#{CONTACT_EMAIL}", :class => "footer-link" %li.footer-link = link_to "Documentation", DOC_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 7fd087644..38bed2226 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -204,7 +204,7 @@ %p.cta-panel-explanation Notre équipe est disponible pour vous renseigner et vous aider %div = link_to "Contactez-nous", - "mailto:#{t("dynamics.contact_email")}?subject=Question%20à%20propos%20de%20demarches-simplifiees.fr", + "mailto:#{CONTACT_EMAIL}?subject=Question%20à%20propos%20de%20demarches-simplifiees.fr", class: "cta-panel-button-white", target: "_blank", rel: "noopener noreferrer" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 1ac79d92e..79919ad70 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -12,7 +12,7 @@ Devise.setup do |config| # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = "demarches-simplifiees.fr <#{I18n.t('dynamics.contact_email')}>" + config.mailer_sender = "demarches-simplifiees.fr <#{CONTACT_EMAIL}>" # Configure the class responsible to send e-mails. config.mailer = 'DeviseUserMailer' diff --git a/config/locales/dynamics/fr.yml b/config/locales/dynamics/fr.yml index fdc533e38..9932fc82b 100644 --- a/config/locales/dynamics/fr.yml +++ b/config/locales/dynamics/fr.yml @@ -1,7 +1,6 @@ fr: dynamics: page_title: demarches-simplifiees.fr - contact_email: contact@demarches-simplifiees.fr users: connexion_title: Connexion mes_dossiers: 'Mes dossiers' diff --git a/lib/tasks/2018_05_30_missed_ar_messages.rake b/lib/tasks/2018_05_30_missed_ar_messages.rake index 6f2cf858e..e3e7a4b90 100644 --- a/lib/tasks/2018_05_30_missed_ar_messages.rake +++ b/lib/tasks/2018_05_30_missed_ar_messages.rake @@ -21,7 +21,7 @@ namespace :'2018_05_30_missed_ar_messages' do Commentaire.create( dossier: dossier, - email: I18n.t("dynamics.contact_email"), + email: CONTACT_EMAIL, body: "[#{subject}]

#{body}", created_at: date ) From e5869f2bec847edad2ffb217972188ef50725e37 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 1 Jun 2018 09:30:14 +0200 Subject: [PATCH 7/7] Remove delayed_job_web version lock Now that the security patches have been patched --- Gemfile | 5 +---- Gemfile.lock | 16 +++++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index c515b2d96..29286a4c0 100644 --- a/Gemfile +++ b/Gemfile @@ -104,10 +104,7 @@ gem 'aasm' gem 'delayed_job_active_record' gem "daemons" gem 'delayed_cron_job' -# FIXME: this is a fork, go back to official version -# once https://github.com/ejschmitt/delayed_job_web/issues/101 -# has been merged and released -gem "delayed_job_web", git: 'https://github.com/breckenedge/delayed_job_web.git', branch: 'cve_2017_12097' +gem "delayed_job_web" gem 'select2-rails' # PDF Generation diff --git a/Gemfile.lock b/Gemfile.lock index a91fc5d90..0e6e5aeb8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,3 @@ -GIT - remote: https://github.com/breckenedge/delayed_job_web.git - revision: 6bcb10e61ea2b9a44ffa16be8536dff46ad51449 - branch: cve_2017_12097 - specs: - delayed_job_web (1.4) - activerecord (> 3.0.0) - delayed_job (> 2.0.3) - sinatra (>= 1.4.4) - GIT remote: https://github.com/hassox/warden.git revision: 5b3cbd5bef67cbe399bb7007537bc4841bbee772 @@ -169,6 +159,10 @@ GEM delayed_job_active_record (4.1.3) activerecord (>= 3.0, < 5.3) delayed_job (>= 3.0, < 5) + delayed_job_web (1.4.2) + activerecord (> 3.0.0) + delayed_job (> 2.0.3) + sinatra (>= 2.0.1) devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -803,7 +797,7 @@ DEPENDENCIES deep_cloneable delayed_cron_job delayed_job_active_record - delayed_job_web! + delayed_job_web devise devise-async dotenv-rails