fix(avis#instruction): use safer claiment.email with a simple helper

This commit is contained in:
Martin 2022-05-24 15:59:28 +02:00 committed by mfo
parent 91f1fa4ffb
commit 25a0daf0a2
3 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
module AvisHelper
def safe_claimant_email(claimant)
claimant&.email || "inconnu"
end
end

View file

@ -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 davis envoyée le #{l(@avis.created_at, format: '%d/%m/%y')}
%p.introduction= @avis.introduction

View file

@ -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')