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
7d57b96e
Commit
7d57b96e
authored
Jun 17, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update authorized/owned resources with new group permissions
parent
5bed576a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
app/models/user.rb
app/models/user.rb
+6
-4
app/views/groups/people.html.haml
app/views/groups/people.html.haml
+6
-1
No files found.
app/models/user.rb
View file @
7d57b96e
...
...
@@ -71,7 +71,9 @@ class User < ActiveRecord::Base
has_many
:keys
,
dependent: :destroy
# Groups
has_many
:groups
,
class_name:
"Group"
,
foreign_key: :owner_id
has_many
:own_groups
,
class_name:
"Group"
,
foreign_key: :owner_id
has_many
:users_groups
,
dependent: :destroy
has_many
:groups
,
through: :users_groups
# Teams
has_many
:own_teams
,
dependent: :destroy
,
class_name:
"UserTeam"
,
foreign_key: :owner_id
...
...
@@ -230,7 +232,7 @@ class User < ActiveRecord::Base
# Groups where user is an owner
def
owned_groups
groups
own_
groups
end
def
owned_teams
...
...
@@ -239,14 +241,14 @@ class User < ActiveRecord::Base
# Groups user has access to
def
authorized_groups
@group_ids
||=
(
groups
.
pluck
(
:id
)
+
authorized_projects
.
pluck
(
:namespace_id
))
@group_ids
||=
(
groups
.
pluck
(
:id
)
+
own_groups
.
pluck
(
:id
)
+
authorized_projects
.
pluck
(
:namespace_id
))
Group
.
where
(
id:
@group_ids
)
end
# Projects user has access to
def
authorized_projects
@project_ids
||=
(
owned_projects
.
pluck
(
:id
)
+
projects
.
pluck
(
:id
)).
uniq
@project_ids
||=
(
owned_projects
.
pluck
(
:id
)
+
groups
.
map
(
&
:projects
).
flatten
.
map
(
&
:id
)
+
projects
.
pluck
(
:id
)).
uniq
Project
.
where
(
id:
@project_ids
)
end
...
...
app/views/groups/people.html.haml
View file @
7d57b96e
-
can_manage_group
=
current_user
.
can?
:manage_group
,
@group
.row
.span6
=
render
"new_group_member"
-
if
can_manage_group
=
render
"new_group_member"
-
else
.light-well
%h4
.nothing_here_message
Only group owners can manage group members
.span6
.ui-box
%h5
.title
...
...
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