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
871723da
Commit
871723da
authored
Jul 25, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate review comments
parent
d1ea2bca
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
10 deletions
+12
-10
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/ability.rb
app/models/ability.rb
+2
-4
app/models/member.rb
app/models/member.rb
+4
-0
app/models/project_team.rb
app/models/project_team.rb
+4
-4
No files found.
app/controllers/projects/issues_controller.rb
View file @
871723da
...
...
@@ -71,7 +71,7 @@ class Projects::IssuesController < Projects::ApplicationController
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@noteable
=
@issue
preload_max_access_for_authors
(
@notes
,
@project
)
if
@notes
preload_max_access_for_authors
(
@notes
,
@project
)
respond_to
do
|
format
|
format
.
html
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
871723da
...
...
@@ -387,7 +387,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@ref
)
preload_max_access_for_authors
(
@notes
,
@project
)
if
@notes
preload_max_access_for_authors
(
@notes
,
@project
)
end
def
define_widget_vars
...
...
app/models/ability.rb
View file @
871723da
...
...
@@ -389,10 +389,8 @@ class Ability
end
def
can_edit_note?
(
user
,
note
)
return
false
unless
note
.
editable?
return
false
unless
user
.
present?
return
true
if
note
.
author
==
user
return
true
if
user
.
admin?
return
false
if
!
note
.
editable?
||
!
user
.
present?
return
true
if
note
.
author
==
user
||
user
.
admin?
if
note
.
project
max_access_level
=
note
.
project
.
team
.
max_member_access
(
user
.
id
)
...
...
app/models/member.rb
View file @
871723da
...
...
@@ -53,6 +53,10 @@ class Member < ActiveRecord::Base
default_value_for
:notification_level
,
NotificationSetting
.
levels
[
:global
]
class
<<
self
def
access_for_user_ids
(
user_ids
)
where
(
user_id:
user_ids
).
has_access
.
pluck
(
:user_id
,
:access_level
).
to_h
end
def
find_by_invite_token
(
invite_token
)
invite_token
=
Devise
.
token_generator
.
digest
(
self
,
:invite_token
,
invite_token
)
find_by
(
invite_token:
invite_token
)
...
...
app/models/project_team.rb
View file @
871723da
...
...
@@ -138,20 +138,20 @@ class ProjectTeam
def
max_member_access_for_user_ids
(
user_ids
)
user_ids
=
user_ids
.
uniq
key
=
"max_member_access:
#{
project
.
id
}
"
RequestStore
.
store
[
key
]
||=
Hash
.
new
RequestStore
.
store
[
key
]
||=
{}
access
=
RequestStore
.
store
[
key
]
# Lookup only the IDs we need
user_ids
=
user_ids
-
access
.
keys
if
user_ids
.
present?
user_ids
.
map
{
|
id
|
access
[
id
]
=
Gitlab
::
Access
::
NO_ACCESS
}
user_ids
.
each
{
|
id
|
access
[
id
]
=
Gitlab
::
Access
::
NO_ACCESS
}
member_access
=
project
.
members
.
where
(
user_id:
user_ids
).
has_access
.
pluck
(
:user_id
,
:access_level
).
to_h
member_access
=
project
.
members
.
access_for_user_ids
(
user_ids
)
merge_max!
(
access
,
member_access
)
if
group
group_access
=
group
.
members
.
where
(
user_id:
user_ids
).
has_access
.
pluck
(
:user_id
,
:access_level
).
to_h
group_access
=
group
.
members
.
access_for_user_ids
(
user_ids
)
merge_max!
(
access
,
group_access
)
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