X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/3d7eb387a7c3573f1a1d17df00adcaa1fb9b9fa5..d1aa084d2804137d2c1d4bf04f7fd5fe319d6772:/app/controllers/notes_controller.rb diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index d25d9a37e..e470bdbea 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -84,7 +84,7 @@ class NotesController < ApplicationController def comment # Check the arguments are sane raise OSM::APIBadUserInput.new("No id was given") unless params[:id] - raise OSM::APIBadUserInput.new("No text was given") unless params[:text] + raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank? # Extract the arguments id = params[:id].to_i @@ -93,7 +93,8 @@ class NotesController < ApplicationController # Find the note and check it is valid @note = Note.find(id) raise OSM::APINotFoundError unless @note - raise OSM::APIAlreadyDeletedError unless @note.visible? + raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? + raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed? # Add a comment to the note Note.transaction do @@ -120,7 +121,8 @@ class NotesController < ApplicationController # Find the note and check it is valid @note = Note.find_by_id(id) raise OSM::APINotFoundError unless @note - raise OSM::APIAlreadyDeletedError unless @note.visible? + raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? + raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed? # Close the note and add a comment Note.transaction do @@ -170,8 +172,8 @@ class NotesController < ApplicationController # Find the note and check it is valid @note = Note.find(params[:id]) raise OSM::APINotFoundError unless @note - raise OSM::APIAlreadyDeletedError unless @note.visible? - + raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? + # Render the result respond_to do |format| format.xml @@ -193,7 +195,7 @@ class NotesController < ApplicationController # Find the note and check it is valid note = Note.find(id) raise OSM::APINotFoundError unless note - raise OSM::APIAlreadyDeletedError unless note.visible? + raise OSM::APIAlreadyDeletedError.new("note", note.id) unless note.visible? # Mark the note as hidden Note.transaction do @@ -236,10 +238,10 @@ class NotesController < ApplicationController if @this_user = User.active.find_by_display_name(params[:display_name]) @title = t 'note.mine.title', :user => @this_user.display_name @heading = t 'note.mine.heading', :user => @this_user.display_name - @description = t 'note.mine.description', :user => render_to_string(:partial => "user", :object => @this_user) + @description = t 'note.mine.subheading', :user => render_to_string(:partial => "user", :object => @this_user) @page = (params[:page] || 1).to_i @page_size = 10 - @notes = @this_user.notes.order("updated_at DESC").offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author) + @notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author) else @title = t 'user.no_such_user.title' @not_found_user = params[:display_name]