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
32ef2f37
Commit
32ef2f37
authored
Jun 18, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add owner to group members after group create
parent
ed9cff9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
+14
-18
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+1
-1
app/models/group.rb
app/models/group.rb
+13
-17
No files found.
app/controllers/groups_controller.rb
View file @
32ef2f37
...
@@ -72,7 +72,7 @@ class GroupsController < ApplicationController
...
@@ -72,7 +72,7 @@ class GroupsController < ApplicationController
def
update
def
update
group_params
=
params
[
:group
].
dup
group_params
=
params
[
:group
].
dup
owner_id
=
group_params
.
delete
(
:owner_id
)
owner_id
=
group_params
.
delete
(
:owner_id
)
if
owner_id
if
owner_id
@group
.
owner
=
User
.
find
(
owner_id
)
@group
.
owner
=
User
.
find
(
owner_id
)
...
...
app/models/group.rb
View file @
32ef2f37
...
@@ -16,29 +16,25 @@ class Group < Namespace
...
@@ -16,29 +16,25 @@ class Group < Namespace
has_many
:users_groups
,
dependent: :destroy
has_many
:users_groups
,
dependent: :destroy
has_many
:users
,
through: :users_groups
has_many
:users
,
through: :users_groups
def
add_users
(
user_ids
,
group_access
)
after_create
:add_owner
user_ids
.
compact
.
each
do
|
user_id
|
self
.
users_groups
.
create
(
user_id:
user_id
,
group_access:
group_access
)
end
end
def
add_users_to_project_teams
(
user_ids
,
project_access
)
UsersProject
.
add_users_into_projects
(
projects
.
map
(
&
:id
),
user_ids
,
project_access
)
end
def
human_name
def
human_name
name
name
end
end
def
truncate_teams
UsersProject
.
truncate_teams
(
project_ids
)
end
def
owners
def
owners
@owners
||=
(
users_groups
.
owners
.
map
(
&
:user
)
<<
owner
)
@owners
||=
(
users_groups
.
owners
.
map
(
&
:user
)
<<
owner
)
end
end
def
add_users
(
user_ids
,
group_access
)
user_ids
.
compact
.
each
do
|
user_id
|
self
.
users_groups
.
create
(
user_id:
user_id
,
group_access:
group_access
)
end
end
private
def
add_owner
self
.
add_users
([
owner
.
id
],
UsersGroup
::
OWNER
)
end
end
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