diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-26 07:43:47 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-26 07:45:23 +0300 |
commit | eeb41c759e246bf96bda8d8f02478860cc6448bb (patch) | |
tree | 769a75a90e011553062806966773893de2cee5e7 /app/controllers/projects/notes_controller.rb | |
parent | ed6c8238f3524feeab187b607362806ed1c666ad (diff) |
Add endpoints to resolve diff notes and discussions
Diffstat (limited to 'app/controllers/projects/notes_controller.rb')
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 0b93dc31ac7..fb9d027ce03 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -5,6 +5,7 @@ class Projects::NotesController < Projects::ApplicationController before_action :authorize_read_note! before_action :authorize_create_note!, only: [:create] before_action :authorize_admin_note!, only: [:update, :destroy] + before_action :authorize_resolve_note!, only: [:resolve] before_action :find_current_user_notes, only: [:index] def index @@ -67,12 +68,18 @@ class Projects::NotesController < Projects::ApplicationController end def resolve - sleep 2 + return render_404 unless note.resolvable? + + note.resolve!(current_user) + head :ok end - def resolve_all - sleep 2 + def unresolve + return render_404 unless note.resolvable? + + note.unresolve! + head :ok end @@ -185,6 +192,10 @@ class Projects::NotesController < Projects::ApplicationController return access_denied! unless can?(current_user, :admin_note, note) end + def authorize_resolve_note! + return access_denied! unless can?(current_user, :resolve_note, note) + end + def note_params params.require(:note).permit( :note, :noteable, :noteable_id, :noteable_type, :project_id, |