ref: master
plugins/stoa/lib/stoa_plugin/person_fields.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
module StoaPlugin::PersonFields HEAVY = %w[image_base64] FILTER = %w[image] EXTRA = %w[tags communities] CUSTOM = %w[first_name surname homepage image_base64 tags communities] ESSENTIAL = %w[username email nusp] AVERAGE = ESSENTIAL + %w[name first_name surname address homepage] FULL = (AVERAGE + Person.fields + HEAVY + EXTRA - FILTER).uniq COMPLETE = FULL - HEAVY FIELDS = { 'none' => {}, 'essential' => ESSENTIAL, 'average' => AVERAGE, 'full' => FULL, 'complete' => COMPLETE } private def selected_fields(kind, user) fields = FIELDS[kind] || FIELDS['essential'] return fields.reject { |field| !FIELDS['essential'].include?(field) } unless user.person.public_profile fields.reject do |field| !user.person.public_fields.include?(field) && !FIELDS['essential'].include?(field) && !CUSTOM.include?(field) end end end |