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
Jérome Perrin
gitlab-ce
Commits
01520d5d
Commit
01520d5d
authored
Aug 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont allow edit or remove of system notes
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
36361f4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+8
-4
app/models/note.rb
app/models/note.rb
+4
-0
app/views/projects/notes/_note.html.haml
app/views/projects/notes/_note.html.haml
+1
-1
No files found.
app/controllers/projects/notes_controller.rb
View file @
01520d5d
...
@@ -30,8 +30,10 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -30,8 +30,10 @@ class Projects::NotesController < Projects::ApplicationController
end
end
def
update
def
update
note
.
update_attributes
(
note_params
)
if
note
.
editable?
note
.
reset_events_cache
note
.
update_attributes
(
note_params
)
note
.
reset_events_cache
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
{
render_note_json
(
note
)
}
format
.
json
{
render_note_json
(
note
)
}
...
@@ -40,8 +42,10 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -40,8 +42,10 @@ class Projects::NotesController < Projects::ApplicationController
end
end
def
destroy
def
destroy
note
.
destroy
if
note
.
editable?
note
.
reset_events_cache
note
.
destroy
note
.
reset_events_cache
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
{
render
nothing:
true
}
format
.
js
{
render
nothing:
true
}
...
...
app/models/note.rb
View file @
01520d5d
...
@@ -337,4 +337,8 @@ class Note < ActiveRecord::Base
...
@@ -337,4 +337,8 @@ class Note < ActiveRecord::Base
def
set_references
def
set_references
notice_added_references
(
project
,
author
)
notice_added_references
(
project
,
author
)
end
end
def
editable?
!
system
end
end
end
app/views/projects/notes/_note.html.haml
View file @
01520d5d
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
%i
.icon-link
%i
.icon-link
Link here
Link here
-
if
(
note
.
author_id
==
current_user
.
try
(
:id
))
||
can?
(
current_user
,
:admin_note
,
@project
)
-
if
can?
(
current_user
,
:admin_note
,
note
)
&&
note
.
editable?
=
link_to
"#"
,
title:
"Edit comment"
,
class:
"js-note-edit"
do
=
link_to
"#"
,
title:
"Edit comment"
,
class:
"js-note-edit"
do
%i
.icon-edit
%i
.icon-edit
Edit
Edit
...
...
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