Commit 6a84d926 authored by Jack Weeden's avatar Jack Weeden

Added update and delete_attachment actions to note controller

parent 5ffc90d9
...@@ -38,6 +38,32 @@ class NotesController < ProjectResourceController ...@@ -38,6 +38,32 @@ class NotesController < ProjectResourceController
end end
end end
def update
@note = @project.notes.find(params[:id])
return access_denied! unless can?(current_user, :admin_note, @note)
@note.update_attributes(params[:note])
respond_to do |format|
format.js do
render js: { success: @note.valid?, id: @note.id, note: view_context.markdown(@note.note) }.to_json
end
format.html do
redirect_to :back
end
end
end
def delete_attachment
@note = @project.notes.find(params[:id])
@note.remove_attachment!
@note.update_attribute(:attachment, nil)
respond_to do |format|
format.js { render nothing: true }
end
end
def preview def preview
render text: view_context.markdown(params[:note]) render text: view_context.markdown(params[:note])
end end
......
...@@ -319,7 +319,10 @@ Gitlab::Application.routes.draw do ...@@ -319,7 +319,10 @@ Gitlab::Application.routes.draw do
end end
end end
resources :notes, only: [:index, :create, :destroy] do resources :notes, only: [:index, :create, :destroy, :update] do
member do
delete :delete_attachment
end
collection do collection do
post :preview post :preview
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment