authorized_projects and authorized_groups methods for user

This commit is contained in:
Dmitriy Zaporozhets 2012-11-29 17:17:01 +02:00
parent 83f2a387d6
commit 9df6f7bfad
4 changed files with 26 additions and 16 deletions

View file

@ -124,11 +124,15 @@ class User < ActiveRecord::Base
end
end
def accessed_groups
@accessed_groups ||= begin
def authorized_groups
@authorized_groups ||= begin
groups = Group.where(id: self.projects.pluck(:namespace_id)).all
groups = groups + self.groups
groups.uniq
end
end
def authorized_projects
Project.authorized_for(self)
end
end