diff options
author | cmrd Senya <senya@riseup.net> | 2015-06-30 22:14:10 +0300 |
---|---|---|
committer | cmrd Senya <senya@riseup.net> | 2015-07-11 04:36:45 +0300 |
commit | 7a5a0a909aac4dc8a0ab661e3069dfba6bf3b767 (patch) | |
tree | bd8df2399aeff5ded87cc1ddeaca8f5a4b0998e0 /app/presenters/person_presenter.rb | |
parent | e0782437b832d8802d5ecf4757e23d8ae6e0ddcb (diff) |
Allow extended profile fields (previously private profile) to be set public (#5684).
This adds a new boolean field "public_details" to person model.
By default it is false and represents old behaviour. When it is
set to true, extended profile (bio,location,gender,birthday)
get available to people who didn't log into diaspora and to
people you don't share with (i.e. it is made public).
In UI, a bootstrap-switch added on the profile-edit page in order to
change the setting.
This also changes wording from public/private profile to basic/extended.
The latter could be public and limited.
Diffstat (limited to 'app/presenters/person_presenter.rb')
-rw-r--r-- | app/presenters/person_presenter.rb | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/app/presenters/person_presenter.rb b/app/presenters/person_presenter.rb index f53087eee..fc8100e52 100644 --- a/app/presenters/person_presenter.rb +++ b/app/presenters/person_presenter.rb @@ -10,41 +10,16 @@ class PersonPresenter < BasePresenter def full_hash base_hash.merge( - relationship: relationship, - block: is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false, - contact: (!own_profile? && has_contact?) ? {id: current_user_person_contact.id} : false, - is_own_profile: own_profile? + relationship: relationship, + block: is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false, + contact: (!own_profile? && has_contact?) ? {id: current_user_person_contact.id} : false, + is_own_profile: own_profile?, + show_profile_info: public_details? || own_profile? || person_is_following_current_user ) end - def full_hash_with_avatar - full_hash.merge(avatar: AvatarPresenter.new(profile).base_hash) - end - - def full_hash_with_profile - attrs = full_hash - - if own_profile? || person_is_following_current_user - attrs.merge!(profile: ProfilePresenter.new(profile).private_hash) - else - attrs.merge!(profile: ProfilePresenter.new(profile).public_hash) - end - - attrs - end - def as_json(_options={}) - attrs = full_hash_with_avatar - - if own_profile? || person_is_following_current_user - attrs.merge!( - location: @presentable.location, - birthday: @presentable.formatted_birthday, - bio: @presentable.bio - ) - end - - attrs + full_hash_with_profile end protected @@ -69,6 +44,18 @@ class PersonPresenter < BasePresenter @presentable.shares_with(current_user) end + def full_hash_with_profile + attrs = full_hash + + if attrs[:show_profile_info] + attrs.merge!(profile: ProfilePresenter.new(profile).private_hash) + else + attrs.merge!(profile: ProfilePresenter.new(profile).public_hash) + end + + attrs + end + private def current_user_person_block |