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
9c574464
Commit
9c574464
authored
Dec 26, 2012
by
Andrey Kumanyaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functional in admin section
parent
17ea019f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
16 deletions
+103
-16
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+10
-1
app/models/project.rb
app/models/project.rb
+1
-0
app/models/users_project.rb
app/models/users_project.rb
+2
-0
app/views/admin/groups/show.html.haml
app/views/admin/groups/show.html.haml
+44
-15
config/routes.rb
config/routes.rb
+1
-0
features/admin/groups.feature
features/admin/groups.feature
+7
-0
features/steps/admin/admin_groups.rb
features/steps/admin/admin_groups.rb
+38
-0
No files found.
app/controllers/admin/groups_controller.rb
View file @
9c574464
class
Admin::GroupsController
<
AdminController
before_filter
:group
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:project_update
]
before_filter
:group
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:project_update
,
:project_teams_update
]
def
index
@groups
=
Group
.
order
(
'name ASC'
)
...
...
@@ -12,6 +12,8 @@ class Admin::GroupsController < AdminController
@projects
=
@projects
.
not_in_group
(
@group
)
if
@group
.
projects
.
present?
@projects
=
@projects
.
all
@projects
.
reject!
(
&
:empty_repo?
)
@users
=
User
.
active
end
def
new
...
...
@@ -65,6 +67,13 @@ class Admin::GroupsController < AdminController
redirect_to
:back
,
notice:
'Group was successfully updated.'
end
def
project_teams_update
@group
.
projects
.
each
do
|
p
|
p
.
add_users_ids_to_team
(
params
[
:user_ids
],
params
[
:project_access
])
end
redirect_to
[
:admin
,
@group
],
notice:
'Users was successfully added.'
end
def
destroy
@group
.
destroy
...
...
app/models/project.rb
View file @
9c574464
...
...
@@ -82,6 +82,7 @@ class Project < ActiveRecord::Base
scope
:public_only
,
where
(
private_flag:
false
)
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:in_group
,
->
(
group
)
{
where
(
namespace_id:
group
.
id
)
}
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
...
...
app/models/users_project.rb
View file @
9c574464
...
...
@@ -33,6 +33,8 @@ class UsersProject < ActiveRecord::Base
delegate
:name
,
:email
,
to: :user
,
prefix:
true
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
class
<<
self
def
import_team
(
source_project
,
target_project
)
UsersProject
.
without_repository_callback
do
...
...
app/views/admin/groups/show.html.haml
View file @
9c574464
...
...
@@ -44,7 +44,9 @@
%div
=
f
.
submit
'Change Owner'
,
class:
"btn danger"
=
link_to
"Cancel"
,
"#"
,
class:
"btn change-owner-cancel-link"
%fieldset
-
if
@group
.
projects
.
any?
%fieldset
%legend
Projects (
#{
@group
.
projects
.
count
}
)
%table
%thead
...
...
@@ -63,6 +65,33 @@
%td
.bgred
=
link_to
'Transfer project to global namespace'
,
remove_project_admin_group_path
(
@group
,
project_id:
project
.
id
),
confirm:
'Remove project from group and move to global namespace. Are you sure?'
,
method: :delete
,
class:
"btn danger small"
=
form_tag
project_teams_update_admin_group_path
(
@group
),
id:
"new_team_member"
,
class:
"bulk_import"
,
method: :put
do
%table
.zebra-striped
%thead
%tr
%th
Users
%th
Project Access:
-
@group
.
users
.
each
do
|
u
|
%tr
{
class:
"user_#{u.id}"
}
%td
.name
=
link_to
u
.
name
,
admin_user_path
(
u
)
%td
.projects_access
-
u
.
projects
.
in_group
(
@group
).
each
do
|
p
|
-
u_p
=
u
.
users_projects
.
in_project
(
p
).
first
=
"
#{
p
.
name
}
(
#{
link_to
u_p
.
project_access_human
,
edit_admin_team_member_path
(
u_p
)
}
)"
.
html_safe
%tr
%td
.input
=
select_tag
:user_ids
,
options_from_collection_for_select
(
@users
,
:id
,
:name
),
multiple:
true
,
data:
{
placeholder:
'Select users'
},
class:
'chosen span5'
%td
=
select_tag
:project_access
,
options_for_select
(
Project
.
access_options
),
{
class:
"project-access-select chosen span3"
}
%tr
%td
=
submit_tag
'Add user to projects in group'
,
class:
"btn primary"
%td
Read more about project permissions
%strong
=
link_to
"here"
,
help_permissions_path
,
class:
"vlink"
-
else
%fieldset
%legend
Group is empty
=
form_tag
project_update_admin_group_path
(
@group
),
class:
"bulk_import"
,
method: :put
do
%fieldset
...
...
config/routes.rb
View file @
9c574464
...
...
@@ -47,6 +47,7 @@ Gitlab::Application.routes.draw do
resources
:groups
,
constraints:
{
id:
/[^\/]+/
}
do
member
do
put
:project_update
put
:project_teams_update
delete
:remove_project
end
end
...
...
features/admin/groups.feature
View file @
9c574464
Feature
:
Admin Groups
Background
:
Given
I sign in as an admin
And
I have group with projects
And
Create gitlab user
"John"
And
I visit admin groups page
Scenario
:
Create a group
...
...
@@ -8,3 +10,8 @@ Feature: Admin Groups
And
submit form with new group info
Then
I should be redirected to group page
And
I should see newly created group
Scenario
:
Add user into projects in group
When
I visit admin group page
When
I select user
"John"
from user list as
"Reporter"
Then
I should see
"John"
in team list in every project as
"Reporter"
features/steps/admin/admin_groups.rb
View file @
9c574464
...
...
@@ -3,10 +3,26 @@ class AdminGroups < Spinach::FeatureSteps
include
SharedPaths
include
SharedActiveTab
When
'I visit admin group page'
do
visit
admin_group_path
(
current_group
)
end
When
'I click new group link'
do
click_link
"New Group"
end
And
'I have group with projects'
do
@group
=
create
(
:group
)
@project
=
create
(
:project
,
group:
@group
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@project
.
add_access
current_user
,
:admin
end
And
'Create gitlab user "John"'
do
create
(
:user
,
:name
=>
"John"
)
end
And
'submit form with new group info'
do
fill_in
'group_name'
,
:with
=>
'gitlab'
click_button
"Create group"
...
...
@@ -19,5 +35,27 @@ class AdminGroups < Spinach::FeatureSteps
Then
'I should be redirected to group page'
do
current_path
.
should
==
admin_group_path
(
Group
.
last
)
end
When
'I select user "John" from user list as "Reporter"'
do
user
=
User
.
find_by_name
(
"John"
)
within
"#new_team_member"
do
select
user
.
name
,
:from
=>
"user_ids"
select
"Reporter"
,
:from
=>
"project_access"
end
click_button
"Add user to projects in group"
end
Then
'I should see "John" in team list in every project as "Reporter"'
do
user
=
User
.
find_by_name
(
"John"
)
projects_with_access
=
find
(
".user_
#{
user
.
id
}
.projects_access"
)
projects_with_access
.
should
have_link
(
"Reporter"
)
end
protected
def
current_group
@group
||=
Group
.
first
end
end
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