X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e91956d0f7ea6f2b0719a1459110ad3a09d2ee9a..565f661f20ad0caca2b91cba4d036ff65ee6e9ec:/app/controllers/changeset_controller.rb diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 6a0ad40a7..735fa73a8 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -210,6 +210,7 @@ class ChangesetController < ApplicationController changesets = conditions_time(changesets, params['time']) changesets = conditions_open(changesets, params['open']) changesets = conditions_closed(changesets, params['closed']) + changesets = conditions_ids(changesets, params['changesets']) # create the results document results = OSM::API.new.get_xml_doc @@ -250,8 +251,8 @@ class ChangesetController < ApplicationController ## # list edits (open changesets) in reverse chronological order def list - if request.format == :atom and params[:page] - redirect_to params.merge({ :page => nil }), :status => :moved_permanently + if request.format == :atom and params[:max_id] + redirect_to params.merge({ :max_id => nil }), :status => :moved_permanently return end @@ -268,7 +269,8 @@ class ChangesetController < ApplicationController return end - if request.format == :html and !params[:bbox] + if request.format == :html and !params[:list] + require_oauth render :action => :history, :layout => map_layout else changesets = conditions_nonempty(Changeset.all) @@ -279,25 +281,19 @@ class ChangesetController < ApplicationController else changesets = changesets.where("false") end - end - - if params[:friends] && @user + elsif params[:bbox] + changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params)) + elsif params[:friends] && @user changesets = changesets.where(:user_id => @user.friend_users.public) - end - - if params[:nearby] && @user + elsif params[:nearby] && @user changesets = changesets.where(:user_id => @user.nearby) end - if params[:bbox] - changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params)) - end - if params[:max_id] changesets = changesets.where("changesets.id <= ?", params[:max_id]) end - @edits = changesets.order("changesets.created_at DESC").limit(20).preload(:user, :changeset_tags) + @edits = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags) render :action => :list, :layout => false end @@ -418,6 +414,20 @@ private end end + ## + # query changesets by a list of ids + # (either specified as array or comma-separated string) + def conditions_ids(changesets, ids) + if ids.nil? + return changesets + elsif ids.empty? + raise OSM::APIBadUserInput.new("No changesets were given to search for") + else + ids = ids.split(',').collect { |n| n.to_i } + return changesets.where(:id => ids) + end + end + ## # eliminate empty changesets (where the bbox has not been set) # this should be applied to all changeset list displays