debian-mirror-gitlab/app/presenters/user_presenter.rb

24 lines
454 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
class UserPresenter < Gitlab::View::Presenter::Delegated
presents :user
2020-12-08 15:28:05 +05:30
def group_memberships
should_be_private? ? GroupMember.none : user.group_members
end
def project_memberships
should_be_private? ? ProjectMember.none : user.project_members
end
private
2021-04-29 21:17:54 +05:30
def can?(*args)
user.can?(*args)
end
2020-12-08 15:28:05 +05:30
def should_be_private?
2021-04-29 21:17:54 +05:30
!Ability.allowed?(current_user, :read_user_profile, user)
2020-12-08 15:28:05 +05:30
end
2019-02-15 15:39:39 +05:30
end