diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /app/serializers/group_group_link_entity.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'app/serializers/group_group_link_entity.rb')
-rw-r--r-- | app/serializers/group_group_link_entity.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/serializers/group_group_link_entity.rb b/app/serializers/group_group_link_entity.rb index 7a51e1a9316..491c672233d 100644 --- a/app/serializers/group_group_link_entity.rb +++ b/app/serializers/group_group_link_entity.rb @@ -1,12 +1,22 @@ # frozen_string_literal: true class GroupGroupLinkEntity < Grape::Entity + include RequestAwareEntity + expose :id expose :created_at expose :expires_at do |group_link| group_link.expires_at&.to_time end + expose :can_update do |group_link| + can_manage?(group_link) + end + + expose :can_remove do |group_link| + can_manage?(group_link) + end + expose :access_level do expose :human_access, as: :string_value expose :group_access, as: :integer_value @@ -23,4 +33,14 @@ class GroupGroupLinkEntity < Grape::Entity expose :shared_with_group, merge: true, using: GroupBasicEntity end + + private + + def current_user + options[:current_user] + end + + def can_manage?(group_link) + can?(current_user, :admin_group_member, group_link.shared_group) + end end |