BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
40 deletions
+45
-40
team_members_controller.rb
app/controllers/team_members_controller.rb
+14
-8
projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
_form.html.haml
app/views/team_members/_form.html.haml
+4
-4
_show.html.haml
app/views/team_members/_show.html.haml
+5
-5
create.js.haml
app/views/team_members/create.js.haml
+1
-1
index.html.haml
app/views/team_members/index.html.haml
+1
-1
show.html.haml
app/views/team_members/show.html.haml
+15
-16
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
end
def
show
@
team_member
=
project
.
users_projects
.
find
(
params
[
:id
]
)
@events
=
@team_member
.
user
.
recent_events
.
where
(
:project_id
=>
@project
.
id
).
limit
(
7
)
@
user_project_relation
=
project
.
users_projects
.
find_by_user_id
(
member
)
@events
=
member
.
recent_events
.
in_projects
(
project
).
limit
(
7
)
end
def
new
@
team_member
=
project
.
users_projects
.
new
@
user_project_relation
=
project
.
users_projects
.
new
end
def
create
...
...
@@ -28,18 +28,18 @@ class TeamMembersController < ProjectResourceController
end
def
update
@
team_member
=
project
.
users_projects
.
find
(
params
[
:id
]
)
@
team_member
.
update_attributes
(
params
[
:team_member
])
@
user_project_relation
=
project
.
users_projects
.
find_by_user_id
(
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"
end
redirect_to
project_team_index_path
(
@project
)
end
def
destroy
@
team_member
=
project
.
users_projects
.
fin
d
(
params
[
:id
])
@
team_member
.
destroy
@
user_project_relation
=
project
.
users_projects
.
find_by_user_i
d
(
params
[
:id
])
@
user_project_relation
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
project_team_index_path
(
@project
)
}
...
...
@@ -54,4 +54,10 @@ class TeamMembersController < ProjectResourceController
redirect_to
project_team_members_path
(
project
),
notice:
notice
end
protected
def
member
@member
||=
User
.
find
(
params
[
:id
])
end
end
app/helpers/projects_helper.rb
View file @
f6f414ce
...
...
@@ -3,8 +3,8 @@ module ProjectsHelper
@project
.
users_projects
.
sort_by
(
&
:project_access
).
reverse
.
group_by
(
&
:project_access
)
end
def
remove_from_
team_message
(
project
,
memb
er
)
"You are going to remove
#{
member
.
user_name
}
from
#{
project
.
name
}
. Are you sure?"
def
remove_from_
project_team_message
(
project
,
us
er
)
"You are going to remove
#{
user
.
name
}
from
#{
project
.
name
}
project team
. Are you sure?"
end
def
link_to_project
project
...
...
app/views/team_members/_form.html.haml
View file @
f6f414ce
%h3
.page_title
=
"New Team member(s)"
%hr
=
form_for
@
team_member
,
as: :team_member
,
url:
project_team_members_path
(
@project
,
@team_member
)
do
|
f
|
-
if
@
team_member
.
errors
.
any?
=
form_for
@
user_project_relation
,
as: :team_member
,
url:
project_team_members_path
(
@project
)
do
|
f
|
-
if
@
user_project_relation
.
errors
.
any?
.alert-message.block-message.error
%ul
-
@
team_member
.
errors
.
full_messages
.
each
do
|
msg
|
-
@
user_project_relation
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
%h6
1. Choose people you want in the team
...
...
@@ -16,7 +16,7 @@
%h6
2. Set access level for them
.clearfix
=
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
=
f
.
submit
'Save'
,
class:
"btn save-btn"
...
...
app/views/team_members/_show.html.haml
View file @
f6f414ce
-
user
=
member
.
user
-
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
.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"
=
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
)
%br
%small
.cgray
=
user
.
email
...
...
@@ -13,7 +13,7 @@
.span5.right
-
if
allow_admin
.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"
.right
-
if
current_user
==
user
...
...
@@ -23,6 +23,6 @@
-
elsif
user
.
blocked
%span
.btn.disabled.blocked
Blocked
-
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
app/views/team_members/create.js.haml
View file @
f6f414ce
-
if
@
team_member
.
valid?
-
if
@
user_project_relation
.
valid?
:plain
$("#new_team_member").hide("slide", { direction: "right" }, 150, function(){
$("#team-table").show("slide", { direction: "left" }, 150, function() {
...
...
app/views/team_members/index.html.haml
View file @
f6f414ce
=
render
"projects/project_head"
%h3
.page_title
Team Members
(
#{
@project
.
users
_projects
.
count
}
)
(
#{
@project
.
users
.
count
}
)
%small
Read more about project permissions
%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
-
user
=
@team_member
.
user
.team_member_show
-
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
=
image_tag
gravatar_icon
(
us
er
.
email
,
60
),
class:
"borders"
=
image_tag
gravatar_icon
(
@memb
er
.
email
,
60
),
class:
"borders"
%h3
.page_title
=
us
er
.
name
%small
(@
#{
us
er
.
username
}
)
=
@memb
er
.
name
%small
(@
#{
@memb
er
.
username
}
)
%hr
.back_link
...
...
@@ -21,34 +20,34 @@
%table
.lite
%tr
%td
Email
%td
=
mail_to
us
er
.
email
%td
=
mail_to
@memb
er
.
email
%tr
%td
Skype
%td
=
us
er
.
skype
-
unless
us
er
.
linkedin
.
blank?
%td
=
@memb
er
.
skype
-
unless
@memb
er
.
linkedin
.
blank?
%tr
%td
LinkedIn
%td
=
us
er
.
linkedin
-
unless
us
er
.
twitter
.
blank?
%td
=
@memb
er
.
linkedin
-
unless
@memb
er
.
twitter
.
blank?
%tr
%td
Twitter
%td
=
us
er
.
twitter
-
unless
us
er
.
bio
.
blank?
%td
=
@memb
er
.
twitter
-
unless
@memb
er
.
bio
.
blank?
%tr
%td
Bio
%td
=
us
er
.
bio
%td
=
@memb
er
.
bio
.span6
%table
.lite
%tr
%td
Member since
%td
=
@
team_member
.
created_at
.
stamp
(
"Aug 21, 2011"
)
%td
=
@
user_project_relation
.
created_at
.
stamp
(
"Aug 21, 2011"
)
%tr
%td
Project Access:
%small
(
#{
link_to
"read more"
,
help_permissions_path
,
class:
"vlink"
}
)
%td
=
form_for
(
@
team_member
,
as: :team_member
,
url:
project_team_member_path
(
@project
,
@team_
member
))
do
|
f
|
=
f
.
select
:project_access
,
options_for_select
(
Project
.
access_options
,
@
team_member
.
project_access
),
{},
class:
"project-access-select"
,
disabled:
!
allow_admin
=
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
,
@
user_project_relation
.
project_access
),
{},
class:
"project-access-select"
,
disabled:
!
allow_admin
%hr
=
render
@events
:javascript
...
...
app/views/team_members/update.js.haml
View file @
f6f414ce
-
if
@
team_member
.
valid?
-
if
@
user_project_relation
.
valid?
:plain
$("##{dom_id(@
team_member
)}").effect("highlight", {color: "#529214"}, 1000);;
$("##{dom_id(@
user_project_relation
)}").effect("highlight", {color: "#529214"}, 1000);;
-
else
: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