Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
4cbb29cf
Commit
4cbb29cf
authored
Dec 27, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix not_in_project scope. Added counters in admin -> users. Improved seeds
parent
e56a47ab
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
105 additions
and
59 deletions
+105
-59
app/models/user.rb
app/models/user.rb
+8
-1
app/views/admin/projects/index.html.haml
app/views/admin/projects/index.html.haml
+1
-1
app/views/admin/users/index.html.haml
app/views/admin/users/index.html.haml
+7
-2
db/fixtures/development/001_admin.rb
db/fixtures/development/001_admin.rb
+0
-10
db/fixtures/development/002_project.rb
db/fixtures/development/002_project.rb
+12
-0
db/fixtures/development/003_users.rb
db/fixtures/development/003_users.rb
+15
-11
db/fixtures/development/004_teams.rb
db/fixtures/development/004_teams.rb
+21
-19
db/fixtures/development/006_wall.rb
db/fixtures/development/006_wall.rb
+5
-3
db/fixtures/development/007_issues.rb
db/fixtures/development/007_issues.rb
+5
-3
db/fixtures/development/008_merge_requests.rb
db/fixtures/development/008_merge_requests.rb
+5
-4
db/fixtures/development/009_source_code.rb
db/fixtures/development/009_source_code.rb
+7
-5
db/fixtures/development/010_keys.rb
db/fixtures/development/010_keys.rb
+8
-0
lib/support/truncate_repositories.sh
lib/support/truncate_repositories.sh
+11
-0
No files found.
app/models/user.rb
View file @
4cbb29cf
...
@@ -77,7 +77,6 @@ class User < ActiveRecord::Base
...
@@ -77,7 +77,6 @@ class User < ActiveRecord::Base
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
delegate
:path
,
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
:admins
,
where
(
admin:
true
)
scope
:admins
,
where
(
admin:
true
)
scope
:blocked
,
where
(
blocked:
true
)
scope
:blocked
,
where
(
blocked:
true
)
scope
:active
,
where
(
blocked:
false
)
scope
:active
,
where
(
blocked:
false
)
...
@@ -93,6 +92,14 @@ class User < ActiveRecord::Base
...
@@ -93,6 +92,14 @@ class User < ActiveRecord::Base
end
end
end
end
def
not_in_project
(
project
)
if
project
.
users
.
present?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
else
scoped
end
end
def
without_projects
def
without_projects
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)'
)
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)'
)
end
end
...
...
app/views/admin/projects/index.html.haml
View file @
4cbb29cf
%h3
.page_title
%h3
.page_title
Projects (
#{
@projects
.
count
}
)
Projects (
#{
Project
.
count
}
)
=
link_to
'New Project'
,
new_project_path
,
class:
"btn small right"
=
link_to
'New Project'
,
new_project_path
,
class:
"btn small right"
%br
%br
=
form_tag
admin_projects_path
,
method: :get
,
class:
'form-inline'
do
=
form_tag
admin_projects_path
,
method: :get
,
class:
'form-inline'
do
...
...
app/views/admin/users/index.html.haml
View file @
4cbb29cf
%h3
.page_title
%h3
.page_title
Users
(
#{
@admin_users
.
count
}
)
Users
=
link_to
'New User'
,
new_admin_user_path
,
class:
"btn small right"
=
link_to
'New User'
,
new_admin_user_path
,
class:
"btn small right"
%br
%br
...
@@ -8,16 +8,21 @@
...
@@ -8,16 +8,21 @@
=
submit_tag
"Search"
,
class:
"btn submit primary"
=
submit_tag
"Search"
,
class:
"btn submit primary"
%ul
.nav.nav-tabs
%ul
.nav.nav-tabs
%li
{
class:
"#{'active' unless params[:filter]}"
}
%li
{
class:
"#{'active' unless params[:filter]}"
}
=
link_to
"Active"
,
admin_users_path
=
link_to
admin_users_path
do
Active
%span
.badge
=
User
.
active
.
count
%li
{
class:
"#{'active' if params[:filter] == "
admins
"}"
}
%li
{
class:
"#{'active' if params[:filter] == "
admins
"}"
}
=
link_to
admin_users_path
(
filter:
"admins"
)
do
=
link_to
admin_users_path
(
filter:
"admins"
)
do
Admins
Admins
%span
.badge
=
User
.
admins
.
count
%li
{
class:
"#{'active' if params[:filter] == "
blocked
"}"
}
%li
{
class:
"#{'active' if params[:filter] == "
blocked
"}"
}
=
link_to
admin_users_path
(
filter:
"blocked"
)
do
=
link_to
admin_users_path
(
filter:
"blocked"
)
do
Blocked
Blocked
%span
.badge
=
User
.
blocked
.
count
%li
{
class:
"#{'active' if params[:filter] == "
wop
"}"
}
%li
{
class:
"#{'active' if params[:filter] == "
wop
"}"
}
=
link_to
admin_users_path
(
filter:
"wop"
)
do
=
link_to
admin_users_path
(
filter:
"wop"
)
do
Without projects
Without projects
%span
.badge
=
User
.
without_projects
.
count
%table
%table
%thead
%thead
...
...
db/fixtures/development/001_admin.rb
View file @
4cbb29cf
...
@@ -9,13 +9,3 @@ User.seed(:id, [
...
@@ -9,13 +9,3 @@ User.seed(:id, [
admin:
true
,
admin:
true
,
}
}
])
])
Key
.
seed
(
:id
,
[
{
id:
1
,
title:
"Sample key"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
,
user_id:
1
,
}
])
db/fixtures/development/002_project.rb
View file @
4cbb29cf
Group
.
seed
(
:id
,
[
Group
.
seed
(
:id
,
[
{
id:
99
,
name:
"GitLab"
,
path:
'gitlab'
,
owner_id:
1
},
{
id:
100
,
name:
"Brightbox"
,
path:
'brightbox'
,
owner_id:
1
},
{
id:
100
,
name:
"Brightbox"
,
path:
'brightbox'
,
owner_id:
1
},
{
id:
101
,
name:
"KDE"
,
path:
'kde'
,
owner_id:
1
},
{
id:
101
,
name:
"KDE"
,
path:
'kde'
,
owner_id:
1
},
])
])
Project
.
seed
(
:id
,
[
Project
.
seed
(
:id
,
[
# Global
{
id:
1
,
name:
"Underscore.js"
,
path:
"underscore"
,
owner_id:
1
},
{
id:
1
,
name:
"Underscore.js"
,
path:
"underscore"
,
owner_id:
1
},
{
id:
2
,
name:
"Diaspora"
,
path:
"diaspora"
,
owner_id:
1
},
{
id:
2
,
name:
"Diaspora"
,
path:
"diaspora"
,
owner_id:
1
},
# Brightbox
{
id:
3
,
namespace_id:
100
,
name:
"Brightbox CLI"
,
path:
"brightbox-cli"
,
owner_id:
1
},
{
id:
3
,
namespace_id:
100
,
name:
"Brightbox CLI"
,
path:
"brightbox-cli"
,
owner_id:
1
},
{
id:
4
,
namespace_id:
100
,
name:
"Puppet"
,
path:
"puppet"
,
owner_id:
1
},
{
id:
4
,
namespace_id:
100
,
name:
"Puppet"
,
path:
"puppet"
,
owner_id:
1
},
# KDE
{
id:
5
,
namespace_id:
101
,
name:
"kdebase"
,
path:
"kdebase"
,
owner_id:
1
},
{
id:
5
,
namespace_id:
101
,
name:
"kdebase"
,
path:
"kdebase"
,
owner_id:
1
},
{
id:
6
,
namespace_id:
101
,
name:
"kdelibs"
,
path:
"kdelibs"
,
owner_id:
1
},
{
id:
6
,
namespace_id:
101
,
name:
"kdelibs"
,
path:
"kdelibs"
,
owner_id:
1
},
{
id:
7
,
namespace_id:
101
,
name:
"amarok"
,
path:
"amarok"
,
owner_id:
1
},
{
id:
7
,
namespace_id:
101
,
name:
"amarok"
,
path:
"amarok"
,
owner_id:
1
},
# GitLab
{
id:
8
,
namespace_id:
99
,
name:
"gitlabhq"
,
path:
"gitlabhq"
,
owner_id:
1
},
{
id:
9
,
namespace_id:
99
,
name:
"gitlab-ci"
,
path:
"gitlab-ci"
,
owner_id:
1
},
{
id:
10
,
namespace_id:
99
,
name:
"gitlab-recipes"
,
path:
"gitlab-recipes"
,
owner_id:
1
},
])
])
db/fixtures/development/003_users.rb
View file @
4cbb29cf
User
.
seed
(
:id
,
[
Gitlab
::
Seeder
.
quiet
do
{
id:
2
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
(
2
..
300
).
each
do
|
i
|
{
id:
3
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
begin
{
id:
4
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
User
.
seed
(
:id
,
[{
{
id:
5
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
id:
i
,
{
id:
6
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
username:
Faker
::
Internet
.
user_name
,
{
id:
7
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
name:
Faker
::
Name
.
name
,
{
id:
8
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
},
email:
Faker
::
Internet
.
email
,
{
id:
9
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
}
}])
])
print
'.'
rescue
ActiveRecord
::
RecordNotSaved
print
'F'
end
end
end
db/fixtures/development/004_teams.rb
View file @
4cbb29cf
UsersProject
.
skip_callback
(
:save
,
:after
,
:update_repository
)
UsersProject
.
skip_callback
(
:save
,
:after
,
:update_repository
)
UsersProject
.
seed
(
:id
,
[
Gitlab
::
Seeder
.
quiet
do
{
:id
=>
1
,
:project_id
=>
1
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
2
,
:project_id
=>
1
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
(
1
..
300
).
each
do
|
i
|
{
:id
=>
3
,
:project_id
=>
1
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTER
},
# Random Project
{
:id
=>
4
,
:project_id
=>
1
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
project
=
Project
.
scoped
.
sample
{
:id
=>
5
,
:project_id
=>
1
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
REPORTER
},
# Random user
{
:id
=>
6
,
:project_id
=>
2
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
user
=
User
.
not_in_project
(
project
).
sample
{
:id
=>
7
,
:project_id
=>
2
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
8
,
:project_id
=>
2
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTER
},
next
unless
user
{
:id
=>
9
,
:project_id
=>
2
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
11
,
:project_id
=>
2
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
MASTER
},
UsersProject
.
seed
(
:id
,
[{
id:
i
,
{
:id
=>
12
,
:project_id
=>
3
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
project_id:
project
.
id
,
{
:id
=>
13
,
:project_id
=>
3
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
user_id:
user
.
id
,
{
:id
=>
14
,
:project_id
=>
3
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
MASTER
},
project_access:
UsersProject
.
access_roles
.
values
.
sample
{
:id
=>
15
,
:project_id
=>
3
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
}])
{
:id
=>
16
,
:project_id
=>
3
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
MASTER
}
])
print
(
'.'
)
end
end
UsersProject
.
set_callback
(
:save
,
:after
,
:update_repository
)
UsersProject
.
set_callback
(
:save
,
:after
,
:update_repository
)
...
...
db/fixtures/development/006_wall.rb
View file @
4cbb29cf
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
(
1
..
300
).
each
do
|
i
|
(
1
..
300
).
each
do
|
i
|
# Random Project
# Random Project
project_id
=
rand
(
2
)
+
1
project
=
Project
.
all
.
sample
project
=
Project
.
find
(
project_id
)
# Random user
# Random user
user
=
project
.
users
.
sample
user
=
project
.
users
.
sample
next
unless
user
user_id
=
user
.
id
user_id
=
user
.
id
Note
.
seed
(
:id
,
[{
Note
.
seed
(
:id
,
[{
id:
i
,
id:
i
,
project_id:
project
_
id
,
project_id:
project
.
id
,
author_id:
user_id
,
author_id:
user_id
,
note:
Faker
::
Lorem
.
sentence
(
6
)
note:
Faker
::
Lorem
.
sentence
(
6
)
}])
}])
...
...
db/fixtures/development/007_issues.rb
View file @
4cbb29cf
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
(
1
..
300
).
each
do
|
i
|
(
1
..
300
).
each
do
|
i
|
# Random Project
# Random Project
project_id
=
rand
(
2
)
+
1
project
=
Project
.
all
.
sample
project
=
Project
.
find
(
project_id
)
# Random user
# Random user
user
=
project
.
users
.
sample
user
=
project
.
users
.
sample
next
unless
user
user_id
=
user
.
id
user_id
=
user
.
id
IssueObserver
.
current_user
=
user
IssueObserver
.
current_user
=
user
Issue
.
seed
(
:id
,
[{
Issue
.
seed
(
:id
,
[{
id:
i
,
id:
i
,
project_id:
project
_
id
,
project_id:
project
.
id
,
author_id:
user_id
,
author_id:
user_id
,
assignee_id:
user_id
,
assignee_id:
user_id
,
closed:
[
true
,
false
].
sample
,
closed:
[
true
,
false
].
sample
,
...
...
db/fixtures/development/008_merge_requests.rb
View file @
4cbb29cf
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
(
1
..
300
).
each
do
|
i
|
(
1
..
300
).
each
do
|
i
|
# Random Project
# Random Project
project_id
=
rand
(
2
)
+
1
project
=
Project
.
all
.
sample
project
=
Project
.
find
(
project_id
)
# Random user
# Random user
user
=
project
.
users
.
sample
user
=
project
.
users
.
sample
next
unless
user
user_id
=
user
.
id
user_id
=
user
.
id
MergeRequestObserver
.
current_user
=
user
MergeRequestObserver
.
current_user
=
user
MergeRequest
.
seed
(
:id
,
[{
MergeRequest
.
seed
(
:id
,
[{
id:
i
,
id:
i
,
source_branch:
'master'
,
source_branch:
'master'
,
target_branch:
'feature'
,
target_branch:
'feature'
,
project_id:
project
_
id
,
project_id:
project
.
id
,
author_id:
user_id
,
author_id:
user_id
,
assignee_id:
user_id
,
assignee_id:
user_id
,
closed:
[
true
,
false
].
sample
,
closed:
[
true
,
false
].
sample
,
...
...
db/fixtures/development/009_source_code.rb
View file @
4cbb29cf
root
=
Gitlab
.
config
.
git
_base
_path
root
=
Gitlab
.
config
.
git
olite
.
repos
_path
projects
=
[
projects
=
[
{
path:
'underscore.git'
,
git:
'https://github.com/documentcloud/underscore.git'
},
{
path:
'underscore.git'
,
git:
'https://github.com/documentcloud/underscore.git'
},
{
path:
'diaspora.git'
,
git:
'https://github.com/diaspora/diaspora.git'
},
{
path:
'diaspora.git'
,
git:
'https://github.com/diaspora/diaspora.git'
},
{
path:
'brightbox/brightbox-cli.git'
,
git:
'https://github.com/brightbox/brightbox-cli.git'
},
{
path:
'brightbox/brightbox-cli.git'
,
git:
'https://github.com/brightbox/brightbox-cli.git'
},
{
path:
'brightbox/puppet.git'
,
git:
'https://github.com/brightbox/puppet.git'
},
{
path:
'brightbox/puppet.git'
,
git:
'https://github.com/brightbox/puppet.git'
},
{
path:
'gitlab/gitlabhq.git'
,
git:
'https://github.com/gitlabhq/gitlabhq.git'
},
{
path:
'gitlab/gitlab-ci.git'
,
git:
'https://github.com/gitlabhq/gitlab-ci.git'
},
{
path:
'gitlab/gitlab-recipres.git'
,
git:
'https://github.com/gitlabhq/gitlab-recipes.git'
},
]
]
projects
.
each
do
|
project
|
projects
.
each
do
|
project
|
project_path
=
File
.
join
(
root
,
project
[
:path
])
project_path
=
File
.
join
(
root
,
project
[
:path
])
next
if
File
.
exists?
(
project_path
)
next
if
File
.
exists?
(
project_path
)
cmds
=
[
cmds
=
[
...
...
db/fixtures/development/010_keys.rb
0 → 100644
View file @
4cbb29cf
Key
.
seed
(
:id
,
[
{
id:
1
,
title:
"Sample key"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
,
user_id:
1
,
}
])
lib/support/truncate_repositories.sh
0 → 100755
View file @
4cbb29cf
#!/bin/bash
echo
"Danger!!! Data Loss"
while
true
;
do
read
-p
"Do you wish to all directories except gitolite-admin.git from /home/git/repositories/ (y/n) ?: "
yn
case
$yn
in
[
Yy]
*
)
sh
-c
"find /home/git/repositories/. -maxdepth 1 -not -name 'gitolite-admin.git' -not -name '.' | xargs sudo rm -rf"
;
break
;;
[
Nn]
*
)
exit
;;
*
)
echo
"Please answer yes or no."
;;
esac
done
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