From 25a0daf0a296dfcb09c426e9e992fd73edca9be1 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 24 May 2022 15:59:28 +0200 Subject: [PATCH] fix(avis#instruction): use safer claiment.email with a simple helper --- app/helpers/avis_helper.rb | 5 +++++ app/views/experts/avis/instruction.html.haml | 2 +- app/views/experts/shared/avis/_list.html.haml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 app/helpers/avis_helper.rb diff --git a/app/helpers/avis_helper.rb b/app/helpers/avis_helper.rb new file mode 100644 index 000000000..f9afdc76d --- /dev/null +++ b/app/helpers/avis_helper.rb @@ -0,0 +1,5 @@ +module AvisHelper + def safe_claimant_email(claimant) + claimant&.email || "inconnu" + end +end diff --git a/app/views/experts/avis/instruction.html.haml b/app/views/experts/avis/instruction.html.haml index 9e904d26b..4fd0e2205 100644 --- a/app/views/experts/avis/instruction.html.haml +++ b/app/views/experts/avis/instruction.html.haml @@ -7,7 +7,7 @@ %h1.tab-title Donner votre avis %h2.claimant Demandeur : - %span.email= @avis.claimant.email + %span.email= safe_claimant_email(@avis.claimant) %span.date Demande d’avis envoyée le #{l(@avis.created_at, format: '%d/%m/%y')} %p.introduction= @avis.introduction diff --git a/app/views/experts/shared/avis/_list.html.haml b/app/views/experts/shared/avis/_list.html.haml index 256c857ee..34c5d7ad6 100644 --- a/app/views/experts/shared/avis/_list.html.haml +++ b/app/views/experts/shared/avis/_list.html.haml @@ -9,7 +9,7 @@ .width-100 %h2.claimant = "#{t('claimant', scope: 'activerecord.attributes.avis')} :" - %span.email= (avis.claimant.email == current_expert.email) ? 'Vous' : avis.claimant.email + %span.email= (safe_claimant_email(avis.claimant) == current_expert.email) ? 'Vous' : safe_claimant_email(avis.claimant) - if avis.confidentiel? %span.confidentiel = t('confidentiel', scope: 'activerecord.attributes.avis')