diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 12:27:21 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 13:05:45 +0100 |
commit | a74d6d204366c862657a545d999cb33dfde300dd (patch) | |
tree | 9737b222b3e549a306b5015609e76f2ee961c581 /app/models/group.rb | |
parent | 01620dd7e7f3015e31ac0288ef71fcfc4f268a14 (diff) | |
download | gitlab-ce-a74d6d204366c862657a545d999cb33dfde300dd.tar.gz |
Group methods for filtering public/visible groups
These methods will be used to get a list of groups, optionally
restricted to only those visible to a given user.
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 2c9e75496b9..1b5b875a19e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -49,6 +49,14 @@ class Group < Namespace def reference_pattern User.reference_pattern end + + def public_and_given_groups(ids) + where('public IS TRUE OR namespaces.id IN (?)', ids) + end + + def visible_to_user(user) + where(id: user.authorized_groups.select(:id).reorder(nil)) + end end def to_reference(_from_project = nil) |