X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/9d3b419aad3069db13fc0169049a30fbc2b2a288..ae27f7adbe561b20203fa639ac1aa50d0408edc0:/app/controllers/notes_controller.rb diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 11d0f8cb4..0544f8705 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -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 @@ -239,7 +241,7 @@ class NotesController < ApplicationController @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]