Commit bdd8a4d05b5ed49c8cf3fab2d425f2907455c433

Authored by Rodrigo Souto
1 parent 56eb1e8b

stoa-api: allow custom fields since their privacy is not customizable

plugins/stoa/controllers/stoa_plugin_controller.rb
@@ -42,15 +42,4 @@ class StoaPluginController < PublicController @@ -42,15 +42,4 @@ class StoaPluginController < PublicController
42 end 42 end
43 end 43 end
44 44
45 - private  
46 -  
47 - def selected_fields(kind, user)  
48 - fields = FIELDS[kind] || FIELDS['essential']  
49 - return fields.reject { |field| !FIELDS['essential'].include?(field) } unless user.person.public_profile  
50 - fields.reject do |field|  
51 - !user.person.public_fields.include?(field) &&  
52 - !FIELDS['essential'].include?(field)  
53 - end  
54 - end  
55 -  
56 end 45 end
plugins/stoa/lib/stoa_plugin/person_fields.rb
1 module StoaPlugin::PersonFields 1 module StoaPlugin::PersonFields
2 HEAVY = %w[image_base64] 2 HEAVY = %w[image_base64]
3 FILTER = %w[image] 3 FILTER = %w[image]
4 - EXTRA = %w[tags] 4 + EXTRA = %w[tags communities]
  5 + CUSTOM = %w[first_name surname homepage image_base64 tags communities]
5 6
6 ESSENTIAL = %w[username email nusp] 7 ESSENTIAL = %w[username email nusp]
7 - AVERAGE = ESSENTIAL + %w[name first_name surname address homepage communities] 8 + AVERAGE = ESSENTIAL + %w[name first_name surname address homepage]
8 FULL = (AVERAGE + Person.fields + HEAVY + EXTRA - FILTER).uniq 9 FULL = (AVERAGE + Person.fields + HEAVY + EXTRA - FILTER).uniq
9 COMPLETE = FULL - HEAVY 10 COMPLETE = FULL - HEAVY
10 11
@@ -15,4 +16,16 @@ module StoaPlugin::PersonFields @@ -15,4 +16,16 @@ module StoaPlugin::PersonFields
15 'full' => FULL, 16 'full' => FULL,
16 'complete' => COMPLETE 17 'complete' => COMPLETE
17 } 18 }
  19 +
  20 + private
  21 +
  22 + def selected_fields(kind, user)
  23 + fields = FIELDS[kind] || FIELDS['essential']
  24 + return fields.reject { |field| !FIELDS['essential'].include?(field) } unless user.person.public_profile
  25 + fields.reject do |field|
  26 + !user.person.public_fields.include?(field) &&
  27 + !FIELDS['essential'].include?(field) &&
  28 + !CUSTOM.include?(field)
  29 + end
  30 + end
18 end 31 end