Ability to create project with namespace
This commit is contained in:
parent
96105e214f
commit
2b683b0d0b
10 changed files with 62 additions and 6 deletions
|
@ -38,13 +38,16 @@ class User < ActiveRecord::Base
|
|||
devise :database_authenticatable, :token_authenticatable, :lockable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
|
||||
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name,
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
|
||||
:skype, :linkedin, :twitter, :dark_scheme, :theme_id, :force_random_password,
|
||||
:extern_uid, :provider, :as => [:default, :admin]
|
||||
attr_accessible :projects_limit, :as => :admin
|
||||
|
||||
attr_accessor :force_random_password
|
||||
|
||||
# Namespace for personal projects
|
||||
has_one :namespace, class_name: "Namespace", foreign_key: :owner_id, conditions: 'type IS NULL', dependent: :destroy
|
||||
|
||||
has_many :keys, dependent: :destroy
|
||||
has_many :projects, through: :users_projects
|
||||
has_many :users_projects, dependent: :destroy
|
||||
|
@ -112,4 +115,11 @@ class User < ActiveRecord::Base
|
|||
self.password = self.password_confirmation = Devise.friendly_token.first(8)
|
||||
end
|
||||
end
|
||||
|
||||
def namespaces
|
||||
namespaces = []
|
||||
namespaces << self.namespace
|
||||
namespaces = namespaces + Group.all if admin
|
||||
namespaces
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue