From eeb41c759e246bf96bda8d8f02478860cc6448bb Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 25 Jul 2016 22:43:47 -0600 Subject: Add endpoints to resolve diff notes and discussions --- app/controllers/projects/notes_controller.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') 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, -- cgit v1.2.1