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
e12c9ee2
Commit
e12c9ee2
authored
Jun 17, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added UsersGroup scaffold. Simplify adding people to group
parent
c9fb7e39
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
76 additions
and
75 deletions
+76
-75
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-0
app/assets/javascripts/groups.js.coffee
app/assets/javascripts/groups.js.coffee
+6
-0
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+3
-15
app/controllers/users_groups_controller.rb
app/controllers/users_groups_controller.rb
+40
-0
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+4
-0
app/models/users_group.rb
app/models/users_group.rb
+1
-0
app/views/groups/_new_group_member.html.haml
app/views/groups/_new_group_member.html.haml
+3
-3
app/views/groups/_new_member.html.haml
app/views/groups/_new_member.html.haml
+0
-18
app/views/groups/_people_filter.html.haml
app/views/groups/_people_filter.html.haml
+0
-22
app/views/groups/people.html.haml
app/views/groups/people.html.haml
+10
-14
app/views/users_groups/_users_group.html.haml
app/views/users_groups/_users_group.html.haml
+5
-1
config/routes.rb
config/routes.rb
+2
-2
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
e12c9ee2
...
...
@@ -32,6 +32,8 @@ class Dispatcher
new
Wall
(
project_id
)
when
'teams:members:index'
new
TeamMembers
()
when
'groups:people'
new
GroupMembers
()
switch
path
.
first
()
when
'admin'
then
new
Admin
()
...
...
app/assets/javascripts/groups.js.coffee
0 → 100644
View file @
e12c9ee2
class
GroupMembers
constructor
:
->
$
(
'li.users_group'
).
bind
'ajax:success'
,
->
$
(
this
).
fadeOut
()
@
GroupMembers
=
GroupMembers
app/controllers/groups_controller.rb
View file @
e12c9ee2
class
GroupsController
<
ApplicationController
respond_to
:html
before_filter
:group
,
except:
[
:new
,
:create
]
before_filter
:group
,
except:
[
:new
,
:create
,
:people
]
# Authorize
before_filter
:authorize_read_group!
,
except:
[
:new
,
:create
]
...
...
@@ -63,20 +63,8 @@ class GroupsController < ApplicationController
def
people
@project
=
group
.
projects
.
find
(
params
[
:project_id
])
if
params
[
:project_id
]
if
@project
@members
=
@project
.
users_projects
@team_member
=
@project
.
users_projects
.
new
else
@members
=
group
.
users_groups
@team_member
=
UsersGroup
.
new
end
end
def
team_members
@group
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:group_access
])
redirect_to
people_group_path
(
@group
),
notice:
'Users were successfully added.'
@users_group
=
UsersGroup
.
new
end
def
edit
...
...
app/controllers/users_groups_controller.rb
0 → 100644
View file @
e12c9ee2
class
UsersGroupsController
<
ApplicationController
before_filter
:group
# Authorize
before_filter
:authorize_admin_group!
layout
'group'
def
create
@group
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:group_access
])
redirect_to
people_group_path
(
@group
),
notice:
'Users were successfully added.'
end
def
update
# TODO: implement
end
def
destroy
@users_group
=
@group
.
users_groups
.
find
(
params
[
:id
])
@users_group
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
people_group_path
(
@group
),
notice:
'User was successfully removed from group.'
}
format
.
js
{
render
nothing:
true
}
end
end
protected
def
group
@group
||=
Group
.
find_by_path
(
params
[
:group_id
])
end
def
authorize_admin_group!
unless
can?
(
current_user
,
:manage_group
,
group
)
return
render_404
end
end
end
app/helpers/groups_helper.rb
View file @
e12c9ee2
...
...
@@ -14,4 +14,8 @@ module GroupsHelper
merge_requests_group_path
(
@group
,
options
)
end
end
def
remove_user_from_group_message
(
group
,
user
)
"You are going to remove
#{
user
.
name
}
from
#{
group
.
name
}
Group. Are you sure?"
end
end
app/models/users_group.rb
View file @
e12c9ee2
...
...
@@ -32,6 +32,7 @@ class UsersGroup < ActiveRecord::Base
validates
:group_access
,
inclusion:
{
in:
UsersGroup
.
group_access_roles
.
values
},
presence:
true
validates
:user_id
,
presence:
true
validates
:group_id
,
presence:
true
validates
:user_id
,
uniqueness:
{
scope:
[
:group_id
],
message:
"already exists in group"
}
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
...
...
app/views/groups/_new_group_member.html.haml
View file @
e12c9ee2
=
form_for
@
team_member
,
as: :team_member
,
url:
team_members_group
_path
(
@group
)
do
|
f
|
=
form_for
@
users_group
,
url:
group_users_groups
_path
(
@group
)
do
|
f
|
%fieldset
%legend
=
"New Group member(s) for
#{
@group
.
name
}
"
%h6
1. Choose people you want in the group
.clearfix
=
f
.
label
:user_ids
,
"People"
.input
=
users_select_tag
(
:user_ids
,
multiple:
true
)
.input
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
'input-large'
)
%h6
2. Set access level for them
.clearfix
=
f
.
label
:group_access
,
"Group Access"
.input
=
select_tag
:group_access
,
options_for_select
(
UsersGroup
.
group_access_roles
,
@
team_member
.
group_access
),
class:
"project-access-select chosen"
.input
=
select_tag
:group_access
,
options_for_select
(
UsersGroup
.
group_access_roles
,
@
users_group
.
group_access
),
class:
"project-access-select chosen"
.form-actions
=
hidden_field_tag
:redirect_to
,
people_group_path
(
@group
)
...
...
app/views/groups/_new_member.html.haml
deleted
100644 → 0
View file @
c9fb7e39
=
form_for
@team_member
,
as: :team_member
,
url:
project_team_members_path
(
@project
,
@team_member
)
do
|
f
|
%fieldset
%legend
=
"New Project member(s) for
#{
@project
.
name
}
"
%h6
1. Choose people you want in the project
.clearfix
=
f
.
label
:user_ids
,
"People"
.input
=
users_select_tag
(
:user_ids
,
multiple:
true
)
%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"
.form-actions
=
hidden_field_tag
:redirect_to
,
people_group_path
(
@group
,
project_id:
@project
.
id
)
=
f
.
submit
'Add users into project'
,
class:
"btn btn-create"
app/views/groups/_people_filter.html.haml
deleted
100644 → 0
View file @
c9fb7e39
%fieldset
%legend
Group members:
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
params
[
:project_id
].
blank?
)}
=
link_to
people_group_path
(
@group
)
do
#{
@group
.
name
}
Group
%small
.pull-right
=
@group
.
users
.
count
=
form_tag
people_group_path
(
@group
),
method:
'get'
do
%fieldset
%legend
Project members:
%ul
.nav.nav-pills.nav-stacked
-
@projects
.
each
do
|
project
|
%li
{
class:
(
"active"
if
params
[
:project_id
]
==
project
.
id
.
to_s
)}
=
link_to
people_group_path
(
@group
,
project_id:
project
.
id
)
do
=
project
.
name_with_namespace
%small
.pull-right
=
project
.
users
.
count
-
if
@projects
.
blank?
%p
.nothing_here_message
This group has no projects yet
app/views/groups/people.html.haml
View file @
e12c9ee2
-
can_manage_group
=
current_user
.
can?
:manage_group
,
@group
.row
.span3
=
render
'people_filter'
.span9
-
if
can?
(
current_user
,
:manage_group
,
@group
)
=
render
(
@project
?
"new_member"
:
"new_group_member"
)
.span6
=
render
"new_group_member"
.span6
.ui-box
%h5
.title
-
if
@project
#{
@project
.
name
}
Project Members
%small
(
#{
@members
.
count
}
)
-
else
#{
@group
.
name
}
Group Members
%small
(
#{
@members
.
count
}
)
%ul
.well-list
-
@members
.
each
do
|
member
|
=
render
'users_groups/users_group'
,
member:
member
=
render
'users_groups/users_group'
,
member:
member
,
show_controls:
can_manage_group
%p
.light
Group members get access to all projects in this group
app/views/users_groups/_users_group.html.haml
View file @
e12c9ee2
-
user
=
member
.
user
-
return
unless
user
%li
%li
{
class:
dom_class
(
member
)}
=
image_tag
gravatar_icon
(
user
.
email
,
16
),
class:
"avatar s16"
%strong
=
user
.
name
%span
.cgray
=
user
.
username
...
...
@@ -10,3 +10,7 @@
%span
.label.label-info
Group Owner
-
else
=
member
.
human_access
-
if
show_controls
&&
user
!=
current_user
=
link_to
group_users_group_path
(
@group
,
member
),
confirm:
remove_user_from_group_message
(
@group
,
user
),
method: :delete
,
remote:
true
,
class:
"btn-tiny btn btn-remove"
,
title:
'Remove user from group'
do
%i
.icon-minus.icon-white
config/routes.rb
View file @
e12c9ee2
...
...
@@ -149,10 +149,10 @@ Gitlab::Application.routes.draw do
member
do
get
:issues
get
:merge_requests
get
:search
get
:people
post
:team_members
end
resources
:users_groups
,
only:
[
:create
,
:update
,
:destroy
]
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