Commit 8e29df88d1219e8144a7945975a2d0f4cfb0f444
Committed by
David Silva
1 parent
d50ac31c
Exists in
fix_optional_fields
Hide field when public checkbox is marked
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -859,8 +859,7 @@ module ApplicationHelper |
859 | 859 | |
860 | 860 | def profile_field_privacy_selector(profile, name) |
861 | 861 | return '' unless profile.public? |
862 | - content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_fields.include?(name)), :class => 'field-privacy-selector') | |
863 | - end | |
862 | + content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_optional_field?(name) ), :class => 'field-privacy-selector') end | |
864 | 863 | |
865 | 864 | def login_url |
866 | 865 | options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) | ... | ... |
app/models/profile.rb
... | ... | @@ -958,7 +958,9 @@ private :generate_url, :url_options |
958 | 958 | if not self.active_fields.include? field.to_s |
959 | 959 | self.send "may_display_#{field}_to?", user rescue true |
960 | 960 | else |
961 | - not (!self.public_fields.include? field.to_s and (!user or (user != self and !user.is_a_friend?(self)))) | |
961 | + if public_optional_field?(field) | |
962 | + not (!self.public_fields.include? field.to_s and (!user or (user != self and !user.is_a_friend?(self)))) | |
963 | + end | |
962 | 964 | end |
963 | 965 | end |
964 | 966 | |
... | ... | @@ -974,6 +976,11 @@ private :generate_url, :url_options |
974 | 976 | self.data[:fields_privacy] |
975 | 977 | end |
976 | 978 | |
979 | + def public_optional_field?(field) | |
980 | + return true if fields_privacy.nil? | |
981 | + fields_privacy[field.to_s] != "0" | |
982 | + end | |
983 | + | |
977 | 984 | def public_fields |
978 | 985 | self.active_fields |
979 | 986 | end | ... | ... |