Added update and delete_attachment actions to note controller
This commit is contained in:
parent
5ffc90d90d
commit
6a84d92672
2 changed files with 30 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue