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
iv
gitlab-ce
Commits
5bf49bb6
Commit
5bf49bb6
authored
May 17, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move note helper method to notes entity file
parent
c9be74e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
lib/api/helpers.rb
lib/api/helpers.rb
+0
-4
lib/api/notes.rb
lib/api/notes.rb
+8
-2
No files found.
lib/api/helpers.rb
View file @
5bf49bb6
...
...
@@ -397,9 +397,5 @@ module API
error!
(
errors
[
:access_level
],
422
)
if
errors
[
:access_level
].
any?
not_found!
(
errors
)
end
def
noteable_ability_name
(
noteable
)
"read_
#{
noteable
.
class
.
to_s
.
underscore
.
downcase
}
"
.
to_sym
end
end
end
lib/api/notes.rb
View file @
5bf49bb6
...
...
@@ -21,7 +21,7 @@ module API
get
":id/
#{
noteables_str
}
/:
#{
noteable_id_str
}
/notes"
do
@noteable
=
user_project
.
send
(
noteables_str
.
to_sym
).
find
(
params
[
noteable_id_str
.
to_sym
])
if
can?
(
current_user
,
noteable_ability_name
(
@noteable
),
@noteable
)
if
can?
(
current_user
,
noteable_
read_
ability_name
(
@noteable
),
@noteable
)
# We exclude notes that are cross-references and that cannot be viewed
# by the current user. By doing this exclusion at this level and not
# at the DB query level (which we cannot in that case), the current
...
...
@@ -51,7 +51,7 @@ module API
get
":id/
#{
noteables_str
}
/:
#{
noteable_id_str
}
/notes/:note_id"
do
@noteable
=
user_project
.
send
(
noteables_str
.
to_sym
).
find
(
params
[
noteable_id_str
.
to_sym
])
@note
=
@noteable
.
notes
.
find
(
params
[
:note_id
])
can_read_note
=
can?
(
current_user
,
noteable_ability_name
(
@noteable
),
@noteable
)
&&
!
@note
.
cross_reference_not_visible_for?
(
current_user
)
can_read_note
=
can?
(
current_user
,
noteable_
read_
ability_name
(
@noteable
),
@noteable
)
&&
!
@note
.
cross_reference_not_visible_for?
(
current_user
)
if
can_read_note
present
@note
,
with:
Entities
::
Note
...
...
@@ -141,5 +141,11 @@ module API
end
end
end
helpers
do
def
noteable_read_ability_name
(
noteable
)
"read_
#{
noteable
.
class
.
to_s
.
underscore
.
downcase
}
"
.
to_sym
end
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