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 %h1.tab-title Donner votre avis
%h2.claimant %h2.claimant
Demandeur : 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')} %span.date Demande davis envoyée le #{l(@avis.created_at, format: '%d/%m/%y')}
%p.introduction= @avis.introduction %p.introduction= @avis.introduction

View file

@ -9,7 +9,7 @@
.width-100 .width-100
%h2.claimant %h2.claimant
= "#{t('claimant', scope: 'activerecord.attributes.avis')} :" = "#{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? - if avis.confidentiel?
%span.confidentiel %span.confidentiel
= t('confidentiel', scope: 'activerecord.attributes.avis') = t('confidentiel', scope: 'activerecord.attributes.avis')