BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ab9d0236
Commit
ab9d0236
authored
Nov 23, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create dir with namespace. Create namespace with user
parent
f17ddeb3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
25 deletions
+38
-25
namespace.rb
app/models/namespace.rb
+7
-0
project.rb
app/models/project.rb
+7
-0
user.rb
app/models/user.rb
+7
-0
user_observer.rb
app/observers/user_observer.rb
+3
-1
_form.html.haml
app/views/admin/users/_form.html.haml
+7
-2
_new_form.html.haml
app/views/projects/_new_form.html.haml
+7
-22
No files found.
app/models/namespace.rb
View file @
ab9d0236
...
@@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base
...
@@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
after_save
:ensure_dir_exist
scope
:root
,
where
(
'type IS NULL'
)
scope
:root
,
where
(
'type IS NULL'
)
def
self
.
search
query
def
self
.
search
query
...
@@ -23,4 +25,9 @@ class Namespace < ActiveRecord::Base
...
@@ -23,4 +25,9 @@ class Namespace < ActiveRecord::Base
def
human_name
def
human_name
owner_name
owner_name
end
end
def
ensure_dir_exist
namespace_dir_path
=
File
.
join
(
Gitlab
.
config
.
git_base_path
,
code
)
Dir
.
mkdir
(
namespace_dir_path
)
unless
File
.
exists?
(
namespace_dir_path
)
end
end
end
app/models/project.rb
View file @
ab9d0236
...
@@ -67,6 +67,7 @@ class Project < ActiveRecord::Base
...
@@ -67,6 +67,7 @@ class Project < ActiveRecord::Base
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validate
:check_limit
,
:repo_name
validate
:check_limit
,
:repo_name
# Scopes
# Scopes
...
@@ -89,6 +90,12 @@ class Project < ActiveRecord::Base
...
@@ -89,6 +90,12 @@ class Project < ActiveRecord::Base
project
=
Project
.
new
params
project
=
Project
.
new
params
Project
.
transaction
do
Project
.
transaction
do
# Build gitlab-hq code from GitLab HQ name
#
slug
=
project
.
name
.
dup
.
parameterize
project
.
code
=
project
.
path
=
slug
project
.
owner
=
user
project
.
owner
=
user
project
.
namespace_id
=
namespace_id
project
.
namespace_id
=
namespace_id
project
.
save!
project
.
save!
...
...
app/models/user.rb
View file @
ab9d0236
...
@@ -63,11 +63,14 @@ class User < ActiveRecord::Base
...
@@ -63,11 +63,14 @@ class User < ActiveRecord::Base
validates
:bio
,
length:
{
within:
0
..
255
}
validates
:bio
,
length:
{
within:
0
..
255
}
validates
:extern_uid
,
:allow_blank
=>
true
,
:uniqueness
=>
{
:scope
=>
:provider
}
validates
:extern_uid
,
:allow_blank
=>
true
,
:uniqueness
=>
{
:scope
=>
:provider
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:username
,
presence:
true
before_validation
:generate_password
,
on: :create
before_validation
:generate_password
,
on: :create
before_save
:ensure_authentication_token
before_save
:ensure_authentication_token
alias_attribute
:private_token
,
:authentication_token
alias_attribute
:private_token
,
:authentication_token
delegate
:code
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
# Scopes
# Scopes
scope
:not_in_project
,
->
(
project
)
{
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
}
scope
:not_in_project
,
->
(
project
)
{
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
}
scope
:admins
,
where
(
admin:
true
)
scope
:admins
,
where
(
admin:
true
)
...
@@ -122,4 +125,8 @@ class User < ActiveRecord::Base
...
@@ -122,4 +125,8 @@ class User < ActiveRecord::Base
namespaces
=
namespaces
+
Group
.
all
if
admin
namespaces
=
namespaces
+
Group
.
all
if
admin
namespaces
namespaces
end
end
def
several_namespaces?
namespaces
.
size
>
1
end
end
end
app/observers/user_observer.rb
View file @
ab9d0236
class
UserObserver
<
ActiveRecord
::
Observer
class
UserObserver
<
ActiveRecord
::
Observer
def
after_create
(
user
)
def
after_create
(
user
)
user
.
create_namespace
(
code:
user
.
username
,
name:
user
.
name
)
log_info
(
"User
\"
#{
user
.
name
}
\"
(
#{
user
.
email
}
) was created"
)
log_info
(
"User
\"
#{
user
.
name
}
\"
(
#{
user
.
email
}
) was created"
)
Notify
.
new_user_email
(
user
.
id
,
user
.
password
).
deliver
Notify
.
new_user_email
(
user
.
id
,
user
.
password
).
deliver
...
@@ -10,7 +12,7 @@ class UserObserver < ActiveRecord::Observer
...
@@ -10,7 +12,7 @@ class UserObserver < ActiveRecord::Observer
end
end
def
after_save
user
def
after_save
user
if
user
.
username_changed?
if
user
.
username_changed?
and
user
.
namespace
user
.
namespace
.
update_attributes
(
code:
user
.
username
)
user
.
namespace
.
update_attributes
(
code:
user
.
username
)
end
end
end
end
...
...
app/views/admin/users/_form.html.haml
View file @
ab9d0236
...
@@ -16,6 +16,11 @@
...
@@ -16,6 +16,11 @@
=
f
.
text_field
:name
=
f
.
text_field
:name
%span
.help-inline
* required
%span
.help-inline
* required
.clearfix
.clearfix
=
f
.
label
:username
.input
=
f
.
text_field
:username
%span
.help-inline
* required
.clearfix
=
f
.
label
:email
=
f
.
label
:email
.input
.input
=
f
.
text_field
:email
=
f
.
text_field
:email
...
@@ -26,11 +31,11 @@
...
@@ -26,11 +31,11 @@
=
f
.
label
:force_random_password
do
=
f
.
label
:force_random_password
do
%span
Generate random password
%span
Generate random password
.input
=
f
.
check_box
:force_random_password
,
{},
true
,
nil
.input
=
f
.
check_box
:force_random_password
,
{},
true
,
nil
%div
.password-fields
%div
.password-fields
.clearfix
.clearfix
=
f
.
label
:password
=
f
.
label
:password
.input
=
f
.
password_field
:password
,
disabled:
f
.
object
.
force_random_password
.input
=
f
.
password_field
:password
,
disabled:
f
.
object
.
force_random_password
.clearfix
.clearfix
=
f
.
label
:password_confirmation
=
f
.
label
:password_confirmation
.input
=
f
.
password_field
:password_confirmation
,
disabled:
f
.
object
.
force_random_password
.input
=
f
.
password_field
:password_confirmation
,
disabled:
f
.
object
.
force_random_password
...
...
app/views/projects/_new_form.html.haml
View file @
ab9d0236
...
@@ -9,27 +9,12 @@
...
@@ -9,27 +9,12 @@
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
=
f
.
submit
'Create project'
,
class:
"btn primary project-submit"
=
f
.
submit
'Create project'
,
class:
"btn primary project-submit"
%hr
-
if
current_user
.
several_namespaces?
%div
.adv_settings
%h6
Advanced settings:
-
if
current_user
.
namespaces
.
size
>
1
.clearfix
=
f
.
label
:namespace_id
do
Namespace
.input
=
f
.
select
:namespace_id
,
namespaces_options
,
{},
{
class:
'chosen'
}
.clearfix
=
f
.
label
:path
do
Git Clone
.input
.input-prepend
%span
.add-on
=
Gitlab
.
config
.
ssh_path
=
f
.
text_field
:path
,
placeholder:
"example_project"
,
disabled:
!
@project
.
new_record?
%span
.add-on
=
".git"
.clearfix
.clearfix
=
f
.
label
:
code
do
=
f
.
label
:
namespace_id
do
URL
%span
.cgray
Namespace
.input
.input
.input-prepend
=
f
.
select
:namespace_id
,
namespaces_options
,
{},
{
class:
'chosen'
}
%span
.add-on
=
web_app_url
%hr
=
f
.
text_field
:code
,
placeholder:
"example"
%p
.padded
All created project are private. You choose who can see project and commit to repository.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment