diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-08-09 15:50:47 -0700 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-08-09 15:50:47 -0700 |
commit | 143ae092712531f09fce5ae06c2ab065835fc1c6 (patch) | |
tree | 4d28318b2ffa88bd7234cf4f1061085ce85a3f0c | |
parent | 7254721b175f5b09f97833579ca1fb44fc1cb925 (diff) | |
download | gitlab-ce-refactor/remove-six.tar.gz |
make can_edit_note? public as wellrefactor/remove-six
-rw-r--r-- | app/models/ability.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 70e37babd39..228a0641faf 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -32,6 +32,19 @@ class Ability issues.select { |issue| issue.visible_to_user?(user) } end + # TODO: make this private and use the actual abilities stuff for this + def can_edit_note?(user, note) + return false if !note.editable? || !user.present? + return true if note.author == user || user.admin? + + if note.project + max_access_level = note.project.team.max_member_access(user.id) + max_access_level >= Gitlab::Access::MASTER + else + false + end + end + def allowed?(user, action, subject) cached_allowed(user, subject).include?(action) end @@ -410,18 +423,6 @@ class Ability GroupProjectsFinder.new(group).execute(user).any? end - def can_edit_note?(user, note) - return false if !note.editable? || !user.present? - return true if note.author == user || user.admin? - - if note.project - max_access_level = note.project.team.max_member_access(user.id) - max_access_level >= Gitlab::Access::MASTER - else - false - end - end - def namespace_abilities(user, namespace) rules = [] |