Create dir with namespace. Create namespace with user

This commit is contained in:
Dmitriy Zaporozhets 2012-11-23 09:11:09 +03:00
parent f17ddeb394
commit ab9d023651
6 changed files with 39 additions and 26 deletions

View file

@ -63,11 +63,14 @@ class User < ActiveRecord::Base
validates :bio, length: { within: 0..255 }
validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider}
validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0}
validates :username, presence: true
before_validation :generate_password, on: :create
before_save :ensure_authentication_token
alias_attribute :private_token, :authentication_token
delegate :code, to: :namespace, allow_nil: true, prefix: true
# Scopes
scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) }
scope :admins, where(admin: true)
@ -122,4 +125,8 @@ class User < ActiveRecord::Base
namespaces = namespaces + Group.all if admin
namespaces
end
def several_namespaces?
namespaces.size > 1
end
end