diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 70610159f..9ff706178 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -566,6 +566,15 @@ class User < Principal @visible_project_ids ||= Project.visible(self).pluck(:id) end + # Returns the roles that the user is allowed to manage for the given project + def managed_roles(project) + if admin? + Role.givable.to_a + else + membership(project).try(:managed_roles) || [] + end + end + # Returns true if user is arg or belongs to arg def is_or_belongs_to?(arg) if arg.is_a?(User) |