diff options
| -rw-r--r-- | app/controllers/projects/notes_controller.rb | 12 | ||||
| -rw-r--r-- | app/models/note.rb | 4 | ||||
| -rw-r--r-- | app/views/projects/notes/_note.html.haml | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 2154b6ed2eb..7b08b79d236 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -30,8 +30,10 @@ class Projects::NotesController < Projects::ApplicationController end def update - note.update_attributes(note_params) - note.reset_events_cache + if note.editable? + note.update_attributes(note_params) + note.reset_events_cache + end respond_to do |format| format.json { render_note_json(note) } @@ -40,8 +42,10 @@ class Projects::NotesController < Projects::ApplicationController end def destroy - note.destroy - note.reset_events_cache + if note.editable? + note.destroy + note.reset_events_cache + end respond_to do |format| format.js { render nothing: true } diff --git a/app/models/note.rb b/app/models/note.rb index 01f72b95c48..0fa1a7ab615 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -337,4 +337,8 @@ class Note < ActiveRecord::Base def set_references notice_added_references(project, author) end + + def editable? + !system + end end diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 90fc554e987..394fa88e045 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -9,7 +9,7 @@ %i.icon-link 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 %i.icon-edit Edit |
