Commit b06e2399a4a9aec1b7811351037f156efc96b2c0
1 parent
4c3176e0
Exists in
profile_api_improvements
Custom Fields Improvements
Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
3 changed files
with
11 additions
and
2 deletions
Show diff stats
app/helpers/forms_helper.rb
... | ... | @@ -7,7 +7,7 @@ module FormsHelper |
7 | 7 | |
8 | 8 | def labelled_check_box( human_name, name, value = "1", checked = false, options = {} ) |
9 | 9 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number |
10 | - html = options[:add_hidden] == false ? "" : hidden_field_tag(name, '0') | |
10 | + html = options[:add_hidden] == false ? "".html_safe : hidden_field_tag(name, '0') | |
11 | 11 | |
12 | 12 | html += check_box_tag( name, value, checked, options ) + |
13 | 13 | content_tag( 'label', human_name, :for => options[:id] ) | ... | ... |
app/models/concerns/customizable.rb
... | ... | @@ -115,6 +115,14 @@ module Customizable |
115 | 115 | return_list |
116 | 116 | end |
117 | 117 | |
118 | + def custom_values_hash | |
119 | + hash = {} | |
120 | + self.custom_field_values.includes(:custom_field).each do |cfv| | |
121 | + hash[cfv.custom_field.name.to_sym] = cfv.value | |
122 | + end | |
123 | + hash | |
124 | + end | |
125 | + | |
118 | 126 | def save_custom_values |
119 | 127 | parse_custom_values.each(&:save) |
120 | 128 | end | ... | ... |
app/models/person.rb
... | ... | @@ -577,7 +577,8 @@ class Person < Profile |
577 | 577 | |
578 | 578 | # by default, all fields are private |
579 | 579 | def public_fields |
580 | - self.fields_privacy.nil? ? [] : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s) | |
580 | + (self.fields_privacy.nil? ? [] : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s) + | |
581 | + self.custom_field_values.includes(:custom_field).reject{ |c| !c.public }.collect{ |f| f.custom_field.name }) | |
581 | 582 | end |
582 | 583 | |
583 | 584 | include Noosfero::Gravatar | ... | ... |