From 185f08f63e7da103a8e0511e435394cedec87e54 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 31 May 2018 15:43:57 +0200 Subject: [PATCH] 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