Added update and delete_attachment actions to note controller

This commit is contained in:
Jack Weeden 2013-06-25 23:46:07 +01:00
parent 5ffc90d90d
commit 6a84d92672
2 changed files with 30 additions and 1 deletions

View file

@ -38,6 +38,32 @@ class NotesController < ProjectResourceController
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
render text: view_context.markdown(params[:note])
end

View file

@ -319,7 +319,10 @@ Gitlab::Application.routes.draw do
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
post :preview
end