Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-01-05 16:36:06 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-01-19 02:38:17 +0300
commitd6b11dafd37e78c12c982c42f274928293cdfa53 (patch)
treee20c62bc3b11b77e366bce2251146d5f5ec86e0c /app/models/ability.rb
parent270dc22658424ee7f279db99e56c6fc69acd3eb7 (diff)
Support notes without project
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r--app/models/ability.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index fa8f8bc3a5f..5bad5c17747 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -22,6 +22,17 @@ class Ability
end
end
+ # Given a list of users and a snippet this method returns the users that can
+ # read the given snippet.
+ def users_that_can_read_personal_snippet(users, snippet)
+ case snippet.visibility_level
+ when Snippet::INTERNAL, Snippet::PUBLIC
+ users
+ when Snippet::PRIVATE
+ users.select { |user| snippet.author == user }
+ end
+ end
+
# Returns an Array of Issues that can be read by the given user.
#
# issues - The issues to reduce down to those readable by the user.