X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/52e5fa6ad78f375cec5a207a123a4aa3939c8ddf..39b20bb85d02b534af2afe0452c28850091132ee:/app/controllers/note_controller.rb diff --git a/app/controllers/note_controller.rb b/app/controllers/note_controller.rb index 1ee529c79..32acea89f 100644 --- a/app/controllers/note_controller.rb +++ b/app/controllers/note_controller.rb @@ -9,9 +9,6 @@ class NoteController < ApplicationController after_filter :compress_output around_filter :api_call_handle_error, :api_call_timeout - # Help methods for checking boundary sanity and area size - include MapBoundary - ## # Return a list of notes in a given area def list @@ -28,9 +25,6 @@ class NoteController < ApplicationController bbox = BoundingBox.from_lrbt_params(params) end - # Get the sanitised boundaries - @min_lon, @min_lat, @max_lon, @max_lat = sanitise_boundaries(bbox) - # Get any conditions that need to be applied notes = closed_condition(Note.scoped) @@ -87,7 +81,7 @@ class NoteController < ApplicationController end # Save the note - @note.save + @note.save! # Add a comment to the note add_comment(@note, comment, name, "opened") @@ -166,7 +160,7 @@ class NoteController < ApplicationController end # Find the comments we want to return - @comments = NoteComment.where(:note => notes).order("created_at DESC").limit(result_limit).include(:note) + @comments = NoteComment.where(:note_id => notes).order("created_at DESC").limit(result_limit).preload(:note) # Render the result respond_to do |format| @@ -228,22 +222,15 @@ class NoteController < ApplicationController raise OSM::APIBadUserInput.new("No query string was given") unless params[:q] # Get any conditions that need to be applied - conditions = closed_condition - conditions = cond_merge conditions, ['note_comments.body ~ ?', params[:q]] - + @notes = closed_condition(Note.scoped) + @notes = @notes.joins(:comments).where("note_comments.body ~ ?", params[:q]) + # Find the notes we want to return - @notes = Note.find(:all, - :conditions => conditions, - :order => "updated_at DESC", - :limit => result_limit, - :joins => :comments, - :include => :comments) + @notes = @notes.order("updated_at DESC").limit(result_limit).preload(:comments) # Render the result respond_to do |format| - format.html { render :action => :list, :format => :rjs, :content_type => "text/javascript"} format.rss { render :action => :list } - format.js format.xml { render :action => :list } format.json { render :action => :list } format.gpx { render :action => :list } @@ -350,7 +337,7 @@ private attributes[:author_name] = name + " (a)" end - note.comments.create(attributes) + note.comments.create(attributes, :without_protection => true) note.comments.map { |c| c.author }.uniq.each do |user| if user and user != @user