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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f6f414ce
Commit
f6f414ce
authored
Jan 22, 2013
by
Andrey Kumanyaev
Committed by
Dmitriy Zaporozhets
Jan 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring project team members controller (corresponding mental model)
parent
ccf8fa4f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
40 deletions
+45
-40
app/controllers/team_members_controller.rb
app/controllers/team_members_controller.rb
+14
-8
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
app/views/team_members/_form.html.haml
app/views/team_members/_form.html.haml
+4
-4
app/views/team_members/_show.html.haml
app/views/team_members/_show.html.haml
+5
-5
app/views/team_members/create.js.haml
app/views/team_members/create.js.haml
+1
-1
app/views/team_members/index.html.haml
app/views/team_members/index.html.haml
+1
-1
app/views/team_members/show.html.haml
app/views/team_members/show.html.haml
+15
-16
app/views/team_members/update.js.haml
app/views/team_members/update.js.haml
+3
-3
No files found.
app/controllers/team_members_controller.rb
View file @
f6f414ce
...
@@ -7,12 +7,12 @@ class TeamMembersController < ProjectResourceController
...
@@ -7,12 +7,12 @@ class TeamMembersController < ProjectResourceController
end
end
def
show
def
show
@
team_member
=
project
.
users_projects
.
find
(
params
[
:id
]
)
@
user_project_relation
=
project
.
users_projects
.
find_by_user_id
(
member
)
@events
=
@team_member
.
user
.
recent_events
.
where
(
:project_id
=>
@project
.
id
).
limit
(
7
)
@events
=
member
.
recent_events
.
in_projects
(
project
).
limit
(
7
)
end
end
def
new
def
new
@
team_member
=
project
.
users_projects
.
new
@
user_project_relation
=
project
.
users_projects
.
new
end
end
def
create
def
create
...
@@ -28,18 +28,18 @@ class TeamMembersController < ProjectResourceController
...
@@ -28,18 +28,18 @@ class TeamMembersController < ProjectResourceController
end
end
def
update
def
update
@
team_member
=
project
.
users_projects
.
find
(
params
[
:id
]
)
@
user_project_relation
=
project
.
users_projects
.
find_by_user_id
(
member
)
@
team_member
.
update_attributes
(
params
[
:team_member
])
@
user_project_relation
.
update_attributes
(
params
[
:team_member
])
unless
@
team_member
.
valid?
unless
@
user_project_relation
.
valid?
flash
[
:alert
]
=
"User should have at least one role"
flash
[
:alert
]
=
"User should have at least one role"
end
end
redirect_to
project_team_index_path
(
@project
)
redirect_to
project_team_index_path
(
@project
)
end
end
def
destroy
def
destroy
@
team_member
=
project
.
users_projects
.
fin
d
(
params
[
:id
])
@
user_project_relation
=
project
.
users_projects
.
find_by_user_i
d
(
params
[
:id
])
@
team_member
.
destroy
@
user_project_relation
.
destroy
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
project_team_index_path
(
@project
)
}
format
.
html
{
redirect_to
project_team_index_path
(
@project
)
}
...
@@ -54,4 +54,10 @@ class TeamMembersController < ProjectResourceController
...
@@ -54,4 +54,10 @@ class TeamMembersController < ProjectResourceController
redirect_to
project_team_members_path
(
project
),
notice:
notice
redirect_to
project_team_members_path
(
project
),
notice:
notice
end
end
protected
def
member
@member
||=
User
.
find
(
params
[
:id
])
end
end
end
app/helpers/projects_helper.rb
View file @
f6f414ce
...
@@ -3,8 +3,8 @@ module ProjectsHelper
...
@@ -3,8 +3,8 @@ module ProjectsHelper
@project
.
users_projects
.
sort_by
(
&
:project_access
).
reverse
.
group_by
(
&
:project_access
)
@project
.
users_projects
.
sort_by
(
&
:project_access
).
reverse
.
group_by
(
&
:project_access
)
end
end
def
remove_from_
team_message
(
project
,
memb
er
)
def
remove_from_
project_team_message
(
project
,
us
er
)
"You are going to remove
#{
member
.
user_name
}
from
#{
project
.
name
}
. Are you sure?"
"You are going to remove
#{
user
.
name
}
from
#{
project
.
name
}
project team
. Are you sure?"
end
end
def
link_to_project
project
def
link_to_project
project
...
...
app/views/team_members/_form.html.haml
View file @
f6f414ce
%h3
.page_title
%h3
.page_title
=
"New Team member(s)"
=
"New Team member(s)"
%hr
%hr
=
form_for
@
team_member
,
as: :team_member
,
url:
project_team_members_path
(
@project
,
@team_member
)
do
|
f
|
=
form_for
@
user_project_relation
,
as: :team_member
,
url:
project_team_members_path
(
@project
)
do
|
f
|
-
if
@
team_member
.
errors
.
any?
-
if
@
user_project_relation
.
errors
.
any?
.alert-message.block-message.error
.alert-message.block-message.error
%ul
%ul
-
@
team_member
.
errors
.
full_messages
.
each
do
|
msg
|
-
@
user_project_relation
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
%li
=
msg
%h6
1. Choose people you want in the team
%h6
1. Choose people you want in the team
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%h6
2. Set access level for them
%h6
2. Set access level for them
.clearfix
.clearfix
=
f
.
label
:project_access
,
"Project Access"
=
f
.
label
:project_access
,
"Project Access"
.input
=
select_tag
:project_access
,
options_for_select
(
Project
.
access_options
,
@
team_member
.
project_access
),
class:
"project-access-select chosen"
.input
=
select_tag
:project_access
,
options_for_select
(
Project
.
access_options
,
@
user_project_relation
.
project_access
),
class:
"project-access-select chosen"
.actions
.actions
=
f
.
submit
'Save'
,
class:
"btn save-btn"
=
f
.
submit
'Save'
,
class:
"btn save-btn"
...
...
app/views/team_members/_show.html.haml
View file @
f6f414ce
-
user
=
member
.
user
-
user
=
member
.
user
-
allow_admin
=
can?
current_user
,
:admin_project
,
@project
-
allow_admin
=
can?
current_user
,
:admin_project
,
@project
%li
{
id:
dom_id
(
memb
er
),
class:
"team_member_row user_#{user.id}"
}
%li
{
id:
dom_id
(
us
er
),
class:
"team_member_row user_#{user.id}"
}
.row
.row
.span6
.span6
=
link_to
project_team_member_path
(
@project
,
memb
er
),
title:
user
.
name
,
class:
"dark"
do
=
link_to
project_team_member_path
(
@project
,
us
er
),
title:
user
.
name
,
class:
"dark"
do
=
image_tag
gravatar_icon
(
user
.
email
,
40
),
class:
"avatar s32"
=
image_tag
gravatar_icon
(
user
.
email
,
40
),
class:
"avatar s32"
=
link_to
project_team_member_path
(
@project
,
memb
er
),
title:
user
.
name
,
class:
"dark"
do
=
link_to
project_team_member_path
(
@project
,
us
er
),
title:
user
.
name
,
class:
"dark"
do
%strong
=
truncate
(
user
.
name
,
lenght:
40
)
%strong
=
truncate
(
user
.
name
,
lenght:
40
)
%br
%br
%small
.cgray
=
user
.
email
%small
.cgray
=
user
.
email
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
.span5.right
.span5.right
-
if
allow_admin
-
if
allow_admin
.left
.left
=
form_for
(
member
,
as: :team_member
,
url:
project_team_member_path
(
@project
,
member
))
do
|
f
|
=
form_for
(
member
,
as: :team_member
,
url:
project_team_member_path
(
@project
,
member
.
user
))
do
|
f
|
=
f
.
select
:project_access
,
options_for_select
(
UsersProject
.
access_roles
,
member
.
project_access
),
{},
class:
"medium project-access-select span2"
=
f
.
select
:project_access
,
options_for_select
(
UsersProject
.
access_roles
,
member
.
project_access
),
{},
class:
"medium project-access-select span2"
.right
.right
-
if
current_user
==
user
-
if
current_user
==
user
...
@@ -23,6 +23,6 @@
...
@@ -23,6 +23,6 @@
-
elsif
user
.
blocked
-
elsif
user
.
blocked
%span
.btn.disabled.blocked
Blocked
%span
.btn.disabled.blocked
Blocked
-
elsif
allow_admin
-
elsif
allow_admin
=
link_to
project_team_member_path
(
project_id:
@project
,
id:
member
.
id
),
confirm:
remove_from_team_message
(
@project
,
memb
er
),
method: :delete
,
class:
"very_small btn danger"
do
=
link_to
project_team_member_path
(
@project
,
user
),
confirm:
remove_from_project_team_message
(
@project
,
us
er
),
method: :delete
,
class:
"very_small btn danger"
do
%i
.icon-minus.icon-white
%i
.icon-minus.icon-white
app/views/team_members/create.js.haml
View file @
f6f414ce
-
if
@
team_member
.
valid?
-
if
@
user_project_relation
.
valid?
:plain
:plain
$("#new_team_member").hide("slide", { direction: "right" }, 150, function(){
$("#new_team_member").hide("slide", { direction: "right" }, 150, function(){
$("#team-table").show("slide", { direction: "left" }, 150, function() {
$("#team-table").show("slide", { direction: "left" }, 150, function() {
...
...
app/views/team_members/index.html.haml
View file @
f6f414ce
=
render
"projects/project_head"
=
render
"projects/project_head"
%h3
.page_title
%h3
.page_title
Team Members
Team Members
(
#{
@project
.
users
_projects
.
count
}
)
(
#{
@project
.
users
.
count
}
)
%small
%small
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"
...
...
app/views/team_members/show.html.haml
View file @
f6f414ce
-
allow_admin
=
can?
current_user
,
:admin_project
,
@project
-
allow_admin
=
can?
current_user
,
:admin_project
,
@project
-
user
=
@team_member
.
user
.team_member_show
.team_member_show
-
if
can?
current_user
,
:admin_project
,
@project
-
if
can?
current_user
,
:admin_project
,
@project
=
link_to
'Remove from team'
,
project_team_member_path
(
project_id:
@project
,
id:
@team_member
.
id
),
confirm:
'Are you sure?'
,
method: :delete
,
class:
"right btn danger"
=
link_to
'Remove from team'
,
project_team_member_path
(
@project
,
@member
),
confirm:
'Are you sure?'
,
method: :delete
,
class:
"right btn danger"
.profile_avatar_holder
.profile_avatar_holder
=
image_tag
gravatar_icon
(
us
er
.
email
,
60
),
class:
"borders"
=
image_tag
gravatar_icon
(
@memb
er
.
email
,
60
),
class:
"borders"
%h3
.page_title
%h3
.page_title
=
us
er
.
name
=
@memb
er
.
name
%small
(@
#{
us
er
.
username
}
)
%small
(@
#{
@memb
er
.
username
}
)
%hr
%hr
.back_link
.back_link
...
@@ -21,34 +20,34 @@
...
@@ -21,34 +20,34 @@
%table
.lite
%table
.lite
%tr
%tr
%td
Email
%td
Email
%td
=
mail_to
us
er
.
email
%td
=
mail_to
@memb
er
.
email
%tr
%tr
%td
Skype
%td
Skype
%td
=
us
er
.
skype
%td
=
@memb
er
.
skype
-
unless
us
er
.
linkedin
.
blank?
-
unless
@memb
er
.
linkedin
.
blank?
%tr
%tr
%td
LinkedIn
%td
LinkedIn
%td
=
us
er
.
linkedin
%td
=
@memb
er
.
linkedin
-
unless
us
er
.
twitter
.
blank?
-
unless
@memb
er
.
twitter
.
blank?
%tr
%tr
%td
Twitter
%td
Twitter
%td
=
us
er
.
twitter
%td
=
@memb
er
.
twitter
-
unless
us
er
.
bio
.
blank?
-
unless
@memb
er
.
bio
.
blank?
%tr
%tr
%td
Bio
%td
Bio
%td
=
us
er
.
bio
%td
=
@memb
er
.
bio
.span6
.span6
%table
.lite
%table
.lite
%tr
%tr
%td
Member since
%td
Member since
%td
=
@
team_member
.
created_at
.
stamp
(
"Aug 21, 2011"
)
%td
=
@
user_project_relation
.
created_at
.
stamp
(
"Aug 21, 2011"
)
%tr
%tr
%td
%td
Project Access:
Project Access:
%small
(
#{
link_to
"read more"
,
help_permissions_path
,
class:
"vlink"
}
)
%small
(
#{
link_to
"read more"
,
help_permissions_path
,
class:
"vlink"
}
)
%td
%td
=
form_for
(
@
team_member
,
as: :team_member
,
url:
project_team_member_path
(
@project
,
@team_
member
))
do
|
f
|
=
form_for
(
@
user_project_relation
,
as: :team_member
,
url:
project_team_member_path
(
@project
,
@
member
))
do
|
f
|
=
f
.
select
:project_access
,
options_for_select
(
Project
.
access_options
,
@
team_member
.
project_access
),
{},
class:
"project-access-select"
,
disabled:
!
allow_admin
=
f
.
select
:project_access
,
options_for_select
(
Project
.
access_options
,
@
user_project_relation
.
project_access
),
{},
class:
"project-access-select"
,
disabled:
!
allow_admin
%hr
%hr
=
render
@events
=
render
@events
:javascript
:javascript
...
...
app/views/team_members/update.js.haml
View file @
f6f414ce
-
if
@
team_member
.
valid?
-
if
@
user_project_relation
.
valid?
:plain
:plain
$("##{dom_id(@
team_member
)}").effect("highlight", {color: "#529214"}, 1000);;
$("##{dom_id(@
user_project_relation
)}").effect("highlight", {color: "#529214"}, 1000);;
-
else
-
else
:plain
:plain
$("##{dom_id(@
team_member
)}").effect("highlight", {color: "#D12F19"}, 1000);;
$("##{dom_id(@
user_project_relation
)}").effect("highlight", {color: "#D12F19"}, 1000);;
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