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
Boxiang Sun
gitlab-ce
Commits
fd0aca12
Commit
fd0aca12
authored
Oct 24, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature implemented
parent
012d62b1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
3 deletions
+58
-3
app/controllers/team_members_controller.rb
app/controllers/team_members_controller.rb
+8
-0
app/models/users_project.rb
app/models/users_project.rb
+16
-0
app/views/team_members/import.html.haml
app/views/team_members/import.html.haml
+17
-0
app/views/team_members/index.html.haml
app/views/team_members/index.html.haml
+7
-2
config/routes.rb
config/routes.rb
+10
-1
No files found.
app/controllers/team_members_controller.rb
View file @
fd0aca12
...
@@ -43,4 +43,12 @@ class TeamMembersController < ProjectResourceController
...
@@ -43,4 +43,12 @@ class TeamMembersController < ProjectResourceController
format
.
js
{
render
nothing:
true
}
format
.
js
{
render
nothing:
true
}
end
end
end
end
def
apply_import
giver
=
Project
.
find
(
params
[
:source_project_id
])
status
=
UsersProject
.
import_team
(
giver
,
project
)
notice
=
status
?
"Succesfully imported"
:
"Import failed"
redirect_to
project_team_members_path
(
project
),
notice:
notice
end
end
end
app/models/users_project.rb
View file @
fd0aca12
...
@@ -21,6 +21,22 @@ class UsersProject < ActiveRecord::Base
...
@@ -21,6 +21,22 @@ class UsersProject < ActiveRecord::Base
delegate
:name
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:email
,
to: :user
,
prefix:
true
class
<<
self
class
<<
self
def
import_team
(
source_project
,
target_project
)
UsersProject
.
transaction
do
team
=
source_project
.
users_projects
.
all
team
.
each
do
|
tm
|
# Skip if user already present in team
next
if
target_project
.
users
.
include?
(
tm
.
user
)
new_tm
=
tm
.
dup
new_tm
.
id
=
nil
new_tm
.
project_id
=
target_project
.
id
new_tm
.
save
end
end
end
def
bulk_delete
(
project
,
user_ids
)
def
bulk_delete
(
project
,
user_ids
)
UsersProject
.
transaction
do
UsersProject
.
transaction
do
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
...
...
app/views/team_members/import.html.haml
0 → 100644
View file @
fd0aca12
=
render
"projects/project_head"
%h3
.page_title
=
"Import team from another project"
%hr
%p
.slead
Read more about team import
#{
link_to
"here"
,
'#'
,
class:
'vlink'
}
.
=
form_tag
apply_import_project_team_members_path
(
@project
),
method:
'post'
do
%p
.slead
Choose project you want to use as team source:
.padded
=
label_tag
:source_project_id
,
"Project"
.input
=
select_tag
(
:source_project_id
,
options_from_collection_for_select
(
current_user
.
projects
,
:id
,
:name
),
prompt:
"Select project"
,
class:
"chosen xxlarge"
,
required:
true
)
.actions
=
submit_tag
'Save'
,
class:
"btn save-btn"
=
link_to
"Cancel"
,
project_team_index_path
(
@project
),
class:
"btn cancel-btn"
app/views/team_members/index.html.haml
View file @
fd0aca12
...
@@ -5,9 +5,14 @@
...
@@ -5,9 +5,14 @@
-
if
can?
current_user
,
:admin_team_member
,
@project
-
if
can?
current_user
,
:admin_team_member
,
@project
%p
.slead
%p
.slead
=
link_to
new_project_team_member_path
(
@project
),
class:
"btn small right"
,
title:
"New Team Member"
do
New Team Member
Read more about project permissions
Read more about project permissions
%strong
=
link_to
"here"
,
help_permissions_path
,
class:
"vlink"
%strong
=
link_to
"here"
,
help_permissions_path
,
class:
"vlink"
%span
.right
=
link_to
import_project_team_members_path
(
@project
),
class:
"btn small grouped"
,
title:
"Import team from another project"
do
Import team from another project
=
link_to
new_project_team_member_path
(
@project
),
class:
"btn success small grouped"
,
title:
"New Team Member"
do
New Team Member
.clearfix
=
render
partial:
"team_members/team"
,
locals:
{
project:
@project
}
=
render
partial:
"team_members/team"
,
locals:
{
project:
@project
}
config/routes.rb
View file @
fd0aca12
...
@@ -188,7 +188,6 @@ Gitlab::Application.routes.draw do
...
@@ -188,7 +188,6 @@ Gitlab::Application.routes.draw do
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
resources
:team
,
controller:
'team_members'
,
only:
[
:index
]
resources
:team
,
controller:
'team_members'
,
only:
[
:index
]
resources
:team_members
resources
:milestones
resources
:milestones
resources
:labels
,
only:
[
:index
]
resources
:labels
,
only:
[
:index
]
resources
:issues
do
resources
:issues
do
...
@@ -199,6 +198,16 @@ Gitlab::Application.routes.draw do
...
@@ -199,6 +198,16 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:team_members
do
collection
do
# Used for import team
# from another project
get
:import
post
:apply_import
end
end
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
]
do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
]
do
collection
do
collection
do
post
:preview
post
:preview
...
...
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