From 2630255db1367c55e77b5e971e363168e34a41c0 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 18 Jun 2009 13:09:52 -0300 Subject: [PATCH] ActionItem1122: don't display disabled fields in profile --- app/helpers/profile_helper.rb | 7 +++++-- app/views/profile/_person.rhtml | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index 6b00a53..132caae 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -1,7 +1,10 @@ module ProfileHelper - def display_field(title, object, field) - value = object.send(field) + def display_field(title, profile, field, force = false) + if !force && !profile.active_fields.include?(field.to_s) + return '' + end + value = profile.send(field) if !value.blank? if block_given? value = yield(value) diff --git a/app/views/profile/_person.rhtml b/app/views/profile/_person.rhtml index 0b68af3..ae9fd17 100644 --- a/app/views/profile/_person.rhtml +++ b/app/views/profile/_person.rhtml @@ -1,10 +1,10 @@ <%= _('Basic information')%> -<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> +<%= display_field(_('Name:'), profile, :name, true) { |name| link_to name, profile.url } %> <%= display_field(_('Sex:'), profile, :sex) { |gender| { 'male' => _('Male'), 'female' => _('Female') }[gender] } %> <%= display_field(_('Date of birth:'), profile, :birth_date) { |date| show_date(date) }%> -<%= display_field(_('Location:'), profile, :location) %> +<%= display_field(_('Location:'), profile, :location, true) %> <% if profile == user || profile.friends.include?(user) %> @@ -13,11 +13,11 @@ <%= display_field(_('Address:'), profile, :address) %> <%= display_field(_('ZIP code:'), profile, :zip_code) %> <%= display_field(_('Contact phone:'), profile, :contact_phone) %> - <%= display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) } %> + <%= display_field(_('e-Mail:'), profile, :email, true) { |email| link_to_email(email) } %> <% end %> <% cache_timeout(profile.identifier + '-profile-relationships', 4.hours.from_now) do %> - <% if !(profile.organization.blank? && profile.organization_website.blank?) %> + <% if !(profile.organization.blank? && profile.organization_website.blank?) && (profile.active_fields.include?('organization') || profile.active_fields.include?('organization_website')) %> <%= _('Work')%> -- libgit2 0.21.2