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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7d3efec7
Commit
7d3efec7
authored
Jan 19, 2013
by
Andrey Kumanyaev
Committed by
Dmitriy Zaporozhets
Jan 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to teams
parent
695becc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
app/models/ability.rb
app/models/ability.rb
+17
-0
No files found.
app/models/ability.rb
View file @
7d3efec7
...
...
@@ -8,6 +8,7 @@ class Ability
when
"Snippet"
then
snippet_abilities
(
object
,
subject
)
when
"MergeRequest"
then
merge_request_abilities
(
object
,
subject
)
when
"Group"
,
"Namespace"
then
group_abilities
(
object
,
subject
)
when
"UserTeam"
then
user_team_abilities
(
object
,
subject
)
else
[]
end
end
...
...
@@ -110,6 +111,22 @@ class Ability
rules
.
flatten
end
def
user_team_abilities
user
,
team
rules
=
[]
# Only group owner and administrators can manage group
if
team
.
owner
==
user
||
team
.
admin?
(
user
)
||
user
.
admin?
rules
<<
[
:manage_user_team
]
end
if
team
.
owner
==
user
||
user
.
admin?
rules
<<
[
:admin_user_team
]
end
rules
.
flatten
end
[
:issue
,
:note
,
:snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
...
...
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