Commit 2630255db1367c55e77b5e971e363168e34a41c0

Authored by Antonio Terceiro
1 parent c8179af4

ActionItem1122: don't display disabled fields in profile

app/helpers/profile_helper.rb
1 module ProfileHelper 1 module ProfileHelper
2 2
3 - def display_field(title, object, field)  
4 - value = object.send(field) 3 + def display_field(title, profile, field, force = false)
  4 + if !force && !profile.active_fields.include?(field.to_s)
  5 + return ''
  6 + end
  7 + value = profile.send(field)
5 if !value.blank? 8 if !value.blank?
6 if block_given? 9 if block_given?
7 value = yield(value) 10 value = yield(value)
app/views/profile/_person.rhtml
1 <tr> 1 <tr>
2 <th colspan='2'><%= _('Basic information')%></th> 2 <th colspan='2'><%= _('Basic information')%></th>
3 </tr> 3 </tr>
4 -<%= display_field(_('Name:'), profile, :name) { |name| link_to name, profile.url } %> 4 +<%= display_field(_('Name:'), profile, :name, true) { |name| link_to name, profile.url } %>
5 <%= display_field(_('Sex:'), profile, :sex) { |gender| { 'male' => _('Male'), 'female' => _('Female') }[gender] } %> 5 <%= display_field(_('Sex:'), profile, :sex) { |gender| { 'male' => _('Male'), 'female' => _('Female') }[gender] } %>
6 <%= display_field(_('Date of birth:'), profile, :birth_date) { |date| show_date(date) }%> 6 <%= display_field(_('Date of birth:'), profile, :birth_date) { |date| show_date(date) }%>
7 -<%= display_field(_('Location:'), profile, :location) %> 7 +<%= display_field(_('Location:'), profile, :location, true) %>
8 8
9 <% if profile == user || profile.friends.include?(user) %> 9 <% if profile == user || profile.friends.include?(user) %>
10 <tr> 10 <tr>
@@ -13,11 +13,11 @@ @@ -13,11 +13,11 @@
13 <%= display_field(_('Address:'), profile, :address) %> 13 <%= display_field(_('Address:'), profile, :address) %>
14 <%= display_field(_('ZIP code:'), profile, :zip_code) %> 14 <%= display_field(_('ZIP code:'), profile, :zip_code) %>
15 <%= display_field(_('Contact phone:'), profile, :contact_phone) %> 15 <%= display_field(_('Contact phone:'), profile, :contact_phone) %>
16 - <%= display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) } %> 16 + <%= display_field(_('e-Mail:'), profile, :email, true) { |email| link_to_email(email) } %>
17 <% end %> 17 <% end %>
18 18
19 <% cache_timeout(profile.identifier + '-profile-relationships', 4.hours.from_now) do %> 19 <% cache_timeout(profile.identifier + '-profile-relationships', 4.hours.from_now) do %>
20 - <% if !(profile.organization.blank? && profile.organization_website.blank?) %> 20 + <% if !(profile.organization.blank? && profile.organization_website.blank?) && (profile.active_fields.include?('organization') || profile.active_fields.include?('organization_website')) %>
21 <tr> 21 <tr>
22 <th colspan='2'><%= _('Work')%></th> 22 <th colspan='2'><%= _('Work')%></th>
23 </tr> 23 </tr>