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
Kazuhiko Shiozaki
gitlab-ce
Commits
9804b7df
Commit
9804b7df
authored
Jan 20, 2013
by
Andrey Kumanyaev
Committed by
Dmitriy Zaporozhets
Jan 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move admin team members management to own controller
parent
9d318db4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
23 deletions
+173
-23
app/controllers/admin/teams/application_controller.rb
app/controllers/admin/teams/application_controller.rb
+12
-0
app/controllers/admin/teams/members_controller.rb
app/controllers/admin/teams/members_controller.rb
+35
-0
app/models/user_team.rb
app/models/user_team.rb
+4
-0
app/views/admin/teams/members/_form.html.haml
app/views/admin/teams/members/_form.html.haml
+20
-0
app/views/admin/teams/members/edit.html.haml
app/views/admin/teams/members/edit.html.haml
+16
-0
app/views/admin/teams/members/new.html.haml
app/views/admin/teams/members/new.html.haml
+29
-0
app/views/admin/teams/show.html.haml
app/views/admin/teams/show.html.haml
+22
-23
config/routes.rb
config/routes.rb
+3
-0
lib/gitlab/user_team_manager.rb
lib/gitlab/user_team_manager.rb
+32
-0
No files found.
app/controllers/admin/teams/application_controller.rb
0 → 100644
View file @
9804b7df
# Provides a base class for Admin controllers to subclass
#
# Automatically sets the layout and ensures an administrator is logged in
class
Admin::Teams::ApplicationController
<
Admin
::
ApplicationController
before_filter
:user_team
private
def
user_team
@team
=
UserTeam
.
find_by_path
(
params
[
:team_id
])
end
end
app/controllers/admin/teams/members_controller.rb
0 → 100644
View file @
9804b7df
class
Admin::Teams::MembersController
<
Admin
::
Teams
::
ApplicationController
def
new
@users
=
User
.
active
@users
=
@users
.
not_in_team
(
@team
)
if
@team
.
members
.
any?
@users
=
UserDecorator
.
decorate
@users
end
def
create
unless
params
[
:user_ids
].
blank?
user_ids
=
params
[
:user_ids
]
access
=
params
[
:default_project_access
]
is_admin
=
params
[
:group_admin
]
@team
.
add_members
(
user_ids
,
access
,
is_admin
)
end
redirect_to
admin_team_path
(
@team
),
notice:
'Members was successfully added.'
end
def
edit
@member
=
@team
.
members
.
find
(
params
[
:id
])
end
def
update
@member
=
@team
.
members
.
find
(
params
[
:id
])
options
=
{
default_projects_access:
params
[
:default_project_access
],
group_admin:
params
[
:group_admin
]}
if
@team
.
update_membership
(
@member
,
options
)
redirect_to
admin_team_path
(
@team
),
notice:
'Membership was successfully updated.'
else
render
:edit
end
end
def
destroy
end
end
app/models/user_team.rb
View file @
9804b7df
...
@@ -64,6 +64,10 @@ class UserTeam < ActiveRecord::Base
...
@@ -64,6 +64,10 @@ class UserTeam < ActiveRecord::Base
Gitlab
::
UserTeamManager
.
remove_member_from_team
(
self
,
user
)
Gitlab
::
UserTeamManager
.
remove_member_from_team
(
self
,
user
)
end
end
def
update_membership
(
user
,
options
)
Gitlab
::
UserTeamManager
.
update_team_user_membership
(
self
,
user
,
options
)
end
def
max_project_access
(
project
)
def
max_project_access
(
project
)
user_team_project_relationships
.
find_by_project_id
(
project
).
greatest_access
user_team_project_relationships
.
find_by_project_id
(
project
).
greatest_access
end
end
...
...
app/views/admin/teams/members/_form.html.haml
0 → 100644
View file @
9804b7df
=
form_tag
admin_team_member_path
(
@team
,
@member
),
method: :put
do
-
if
@member
.
errors
.
any?
.alert-message.block-message.error
%ul
-
@member
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.clearfix
%label
Default access for Team projects:
.input
=
select_tag
:default_project_access
,
options_for_select
(
UserTeam
.
access_roles
,
@team
.
default_projects_access
(
@member
)),
class:
"project-access-select chosen span3"
.clearfix
%label
Team admin?
.input
=
check_box_tag
:group_admin
,
true
,
@team
.
admin?
(
@member
)
%br
.actions
=
submit_tag
'Save'
,
class:
"btn primary"
=
link_to
'Cancel'
,
:back
,
class:
"btn"
app/views/admin/teams/members/edit.html.haml
0 → 100644
View file @
9804b7df
%h3
Edit access
#{
@member
.
name
}
in
#{
@team
.
name
}
team
%hr
%table
.zebra-striped
%tr
%td
User:
%td
=
@member
.
name
%tr
%td
Team:
%td
=
@team
.
name
%tr
%td
Since:
%td
=
member_since
(
@team
,
@member
).
stamp
(
"Nov 11, 2010"
)
=
render
'form'
app/views/admin/teams/members/new.html.haml
0 → 100644
View file @
9804b7df
%h3
.page_title
Team:
#{
@team
.
name
}
%fieldset
%legend
Members (
#{
@team
.
members
.
count
}
)
=
form_tag
add_members_admin_team_path
(
@team
),
id:
"team_members"
,
class:
"bulk_import"
,
method: :post
do
%table
#members_list
%thead
%tr
%th
User name
%th
Default project access
%th
Team access
%th
-
@team
.
members
.
each
do
|
member
|
%tr
.member
%td
=
link_to
[
:admin
,
member
]
do
=
member
.
name
%small
=
"(
#{
member
.
email
}
)"
%td
=
@team
.
human_default_projects_access
(
member
)
%td
=
@team
.
admin?
(
member
)
?
"Admin"
:
"Member"
%td
%tr
%td
=
select_tag
:user_ids
,
options_from_collection_for_select
(
@users
,
:id
,
:name_with_email
),
multiple:
true
,
data:
{
placeholder:
'Select users'
},
class:
'chosen span5'
%td
=
select_tag
:default_project_access
,
options_for_select
(
Project
.
access_options
),
{
class:
"project-access-select chosen span3"
}
%td
%span
=
check_box_tag
:group_admin
%span
Admin?
%td
=
submit_tag
'Add'
,
class:
"btn primary"
,
id: :add_members_to_team
app/views/admin/teams/show.html.haml
View file @
9804b7df
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
%fieldset
%fieldset
%legend
Members (
#{
@team
.
members
.
count
}
)
%legend
Members (
#{
@team
.
members
.
count
}
)
=
form_tag
add_members_admin_team_path
(
@team
),
id:
"team_members"
,
class:
"bulk_import"
,
method: :post
do
%table
#members_list
%table
#members_list
%thead
%thead
%tr
%tr
...
@@ -58,14 +57,14 @@
...
@@ -58,14 +57,14 @@
%td
=
@team
.
human_default_projects_access
(
member
)
%td
=
@team
.
human_default_projects_access
(
member
)
%td
=
@team
.
admin?
(
member
)
?
"Admin"
:
"Member"
%td
=
@team
.
admin?
(
member
)
?
"Admin"
:
"Member"
%td
.bgred
%td
.bgred
=
link_to
'Remove'
,
remove_member_admin_team_path
(
@team
,
member_id:
member
.
id
),
confirm:
'Remove project from team and move to global namespace. Are you sure?'
,
method: :delete
,
class:
"btn danger small"
=
link_to
'Edit'
,
edit_admin_team_member_path
(
@team
,
member
),
class:
"btn small"
=
link_to
'Remove'
,
admin_team_member_path
(
@team
,
member
),
confirm:
'Remove member from team. Are you sure?'
,
method: :delete
,
class:
"btn danger small"
%tr
%tr
%td
=
select_tag
:user_ids
,
options_from_collection_for_select
(
@users
,
:id
,
:name_with_email
),
multiple:
true
,
data:
{
placeholder:
'Select users'
},
class:
'chosen span5'
%td
=
select_tag
:default_project_access
,
options_for_select
(
Project
.
access_options
),
{
class:
"project-access-select chosen span3"
}
%td
%td
%span
=
check_box_tag
:group_admin
%td
%span
Admin?
%td
%td
=
submit_tag
'Add'
,
class:
"btn primary"
,
id: :add_members_to_team
%td
=
link_to
'Add members'
,
new_admin_team_member_path
(
@team
)
,
class:
"btn primary"
,
id: :add_members_to_team
%fieldset
%fieldset
%legend
Projects (
#{
@team
.
projects
.
count
}
)
%legend
Projects (
#{
@team
.
projects
.
count
}
)
...
...
config/routes.rb
View file @
9804b7df
...
@@ -77,6 +77,9 @@ Gitlab::Application.routes.draw do
...
@@ -77,6 +77,9 @@ Gitlab::Application.routes.draw do
post
:add_members
post
:add_members
delete
:remove_member
delete
:remove_member
end
end
scope
module: :teams
do
resources
:members
,
only:
[
:edit
,
:update
,
:destroy
,
:new
,
:create
]
end
end
end
resources
:team_members
,
only:
[
:edit
,
:update
,
:destroy
]
resources
:team_members
,
only:
[
:edit
,
:update
,
:destroy
]
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
]
do
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
]
do
...
...
lib/gitlab/user_team_manager.rb
View file @
9804b7df
...
@@ -22,6 +22,38 @@ module Gitlab
...
@@ -22,6 +22,38 @@ module Gitlab
update_team_users_access_in_project
(
team
,
project
)
update_team_users_access_in_project
(
team
,
project
)
end
end
def
update_team_user_membership
(
team
,
member
,
options
)
updates
=
{}
if
options
[
:default_projects_access
]
&&
options
[
:default_projects_access
]
!=
team
.
default_projects_access
(
member
)
updates
[
:permission
]
=
options
[
:default_projects_access
]
end
if
options
[
:group_admin
].
to_s
!=
team
.
admin?
(
member
).
to_s
updates
[
:group_admin
]
=
options
[
:group_admin
].
present?
end
unless
updates
.
blank?
user_team_relationship
=
team
.
user_team_user_relationships
.
find_by_user_id
(
member
)
if
user_team_relationship
.
update_attributes
(
updates
)
if
updates
[
:permission
]
rebuild_project_permissions_to_member
(
team
,
member
)
end
true
else
false
end
else
true
end
end
def
rebuild_project_permissions_to_member
(
team
,
member
)
team
.
projects
.
each
do
|
project
|
update_team_user_access_in_project
(
team
,
member
,
project
)
end
end
def
update_team_users_access_in_project
(
team
,
project
)
def
update_team_users_access_in_project
(
team
,
project
)
members
=
team
.
members
members
=
team
.
members
members
.
each
do
|
member
|
members
.
each
do
|
member
|
...
...
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