From d53d8b6993b16282a29ca2e1573023261f8b4858 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 28 Jan 2014 18:40:20 +0000 Subject: [PATCH] profile-helper: refactor display_contact and add html-safe to string concatenation --- app/helpers/profile_helper.rb | 17 +++++++++-------- app/models/person.rb | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index eb6ad68..b79ee9c 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -16,16 +16,17 @@ module ProfileHelper end def display_contact(profile) - address = display_field(_('Address:'), profile, :address) - zip = display_field(_('ZIP code:'), profile, :zip_code) - phone = display_field(_('Contact phone:'), profile, :contact_phone) - email = display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) } - personal_website = display_field(_('Personal website:'), profile, :personal_website) - jabber = display_field(_('Jabber:'), profile, :jabber_id) - if address.blank? && zip.blank? && phone.blank? && email.blank? && personal_website.blank? && jabber.blank? + fields = [] + fields << display_field(_('Address:'), profile, :address).html_safe + fields << display_field(_('ZIP code:'), profile, :zip_code).html_safe + fields << display_field(_('Contact phone:'), profile, :contact_phone).html_safe + fields << display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) }.html_safe + fields << display_field(_('Personal website:'), profile, :personal_website).html_safe + fields << display_field(_('Jabber:'), profile, :jabber_id).html_safe + if fields.reject!(&:blank?).empty? '' else - content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + address + zip + phone + email + personal_website + jabber + content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + fields.join.html_safe end end diff --git a/app/models/person.rb b/app/models/person.rb index b25866b..a7f4b49 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -158,7 +158,7 @@ class Person < Profile district zip_code address - address_reference + address_reference cell_phone comercial_phone personal_website -- libgit2 0.21.2