diff options
| author | Douwe Maan <douwe@gitlab.com> | 2017-07-04 15:00:01 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2017-07-04 15:00:01 +0000 |
| commit | 5e2f7f25eb6ed1118cb541e43026915a7c4cdfef (patch) | |
| tree | fbb893941818f2c9f0f1ce89dd5daf9d67ed00aa /lib/api/entities.rb | |
| parent | afbc7520c296196d0f3f95d4a24a9e42c0e41f3c (diff) | |
| parent | 016b9f2565f85b9c77a5a779b64483ca1d4e1776 (diff) | |
| download | gitlab-ce-5e2f7f25eb6ed1118cb541e43026915a7c4cdfef.tar.gz | |
Merge branch 'master' into '33580-fix-api-scoping'
# Conflicts:
# lib/api/users.rb
Diffstat (limited to 'lib/api/entities.rb')
| -rw-r--r-- | lib/api/entities.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index aa91451c9f4..cef5a0abe12 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -444,7 +444,15 @@ module API end class Namespace < Grape::Entity - expose :id, :name, :path, :kind, :full_path + expose :id, :name, :path, :kind, :full_path, :parent_id + + expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _| + namespace.users_with_descendants.count + end + + def expose_members_count_with_descendants?(namespace, opts) + namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace) + end end class MemberAccess < Grape::Entity |
