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

56 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
class MemberPresenter < Gitlab::View::Presenter::Delegated
2021-11-18 22:05:49 +05:30
presents ::Member, as: :member
2018-03-17 18:26:18 +05:30
def access_level_roles
member.class.access_level_roles
end
2019-02-15 15:39:39 +05:30
def valid_level_roles
return access_level_roles unless member.highest_group_member
access_level_roles.reject do |_name, level|
member.highest_group_member.access_level > level
end
end
2018-03-17 18:26:18 +05:30
def can_resend_invite?
invite? &&
can?(current_user, admin_member_permission, source)
end
def can_update?
can?(current_user, update_member_permission, member)
end
def can_remove?
can?(current_user, destroy_member_permission, member)
end
def can_approve?
request? && can_update?
end
2019-09-04 21:01:54 +05:30
# This functionality is only available in EE.
def can_override?
false
end
2018-03-17 18:26:18 +05:30
private
def admin_member_permission
raise NotImplementedError
end
def update_member_permission
raise NotImplementedError
end
def destroy_member_permission
raise NotImplementedError
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
MemberPresenter.prepend_mod_with('MemberPresenter')