Allow project creation in scope of group for non-admin but group owners

This commit is contained in:
Dmitriy Zaporozhets 2012-11-25 11:57:01 +02:00
parent 2f22874ba6
commit c31d48dd25
7 changed files with 62 additions and 13 deletions

View file

@ -48,6 +48,7 @@ class User < ActiveRecord::Base
# Namespace for personal projects
has_one :namespace, class_name: "Namespace", foreign_key: :owner_id, conditions: 'type IS NULL', dependent: :destroy
has_many :groups, class_name: "Group", foreign_key: :owner_id
has_many :keys, dependent: :destroy
has_many :projects, through: :users_projects
@ -120,15 +121,4 @@ class User < ActiveRecord::Base
self.password = self.password_confirmation = Devise.friendly_token.first(8)
end
end
def namespaces
namespaces = []
namespaces << self.namespace if self.namespace
namespaces = namespaces + Group.all if admin
namespaces
end
def several_namespaces?
namespaces.size > 1
end
end