X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dc35b597a2210d77e3d3e6996138dfdeb3add4a3..dd7ef37ec023646120358a0a6a7959a392b79f1c:/app/controllers/changeset_controller.rb diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 1b77d48ee..29b9c787b 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -4,16 +4,17 @@ class ChangesetController < ApplicationController layout 'site' require 'xml/libxml' - before_filter :authorize_web, :only => [:list, :list_user, :list_bbox] - before_filter :set_locale, :only => [:list, :list_user, :list_bbox] + before_filter :authorize_web, :only => [:list] + before_filter :set_locale, :only => [:list] before_filter :authorize, :only => [:create, :update, :delete, :upload, :include, :close] before_filter :require_allow_write_api, :only => [:create, :update, :delete, :upload, :include, :close] before_filter :require_public_data, :only => [:create, :update, :delete, :upload, :include, :close] before_filter :check_api_writable, :only => [:create, :update, :delete, :upload, :include] - before_filter :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query] + before_filter :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query, :list] + before_filter(:only => [:list]) { |c| c.check_database_readable(true) } after_filter :compress_output - around_filter :api_call_handle_error, :except => [:list, :list_user, :list_bbox] - around_filter :web_timeout, :only => [:list, :list_user, :list_bbox] + around_filter :api_call_handle_error, :except => [:list] + around_filter :web_timeout, :only => [:list] filter_parameter_logging " { :status => ["active", "confirmed"] }) + if request.format == :atom and params[:page] + redirect_to params.merge({ :page => nil }), :status => :moved_permanently + else + conditions = conditions_nonempty - if user - if user.data_public? or user == @user - conditions = cond_merge conditions, ['user_id = ?', user.id] - else - conditions = cond_merge conditions, ['false'] + if params[:display_name] + user = User.find_by_display_name(params[:display_name], :conditions => { :status => ["active", "confirmed"] }) + + if user + if user.data_public? or user == @user + conditions = cond_merge conditions, ['user_id = ?', user.id] + else + conditions = cond_merge conditions, ['false'] + end + elsif request.format == :html + @title = t 'user.no_such_user.title' + @not_found_user = params[:display_name] + render :template => 'user/no_such_user', :status => :not_found end - elsif request.format == :html - @title = t 'user.no_such_user.title' - @not_found_user = params[:display_name] - render :template => 'user/no_such_user', :status => :not_found end - end - - if params[:bbox] - bbox = params[:bbox] - elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat] - bbox = params[:minlon] + ',' + params[:minlat] + ',' + params[:maxlon] + ',' + params[:maxlat] - end - - if bbox - conditions = cond_merge conditions, conditions_bbox(bbox) - bbox = BoundingBox.from_s(bbox) - bbox_link = render_to_string :partial => "bbox", :object => bbox - end + + if params[:bbox] + bbox = params[:bbox] + elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat] + bbox = params[:minlon] + ',' + params[:minlat] + ',' + params[:maxlon] + ',' + params[:maxlat] + end + + if bbox + conditions = cond_merge conditions, conditions_bbox(bbox) + bbox = BoundingBox.from_s(bbox) + bbox_link = render_to_string :partial => "bbox", :object => bbox + end + + if user + user_link = render_to_string :partial => "user", :object => user + end + + if user and bbox + @title = t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s + @heading = t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s + @description = t 'changeset.list.description_user_bbox', :user => user_link, :bbox => bbox_link + elsif user + @title = t 'changeset.list.title_user', :user => user.display_name + @heading = t 'changeset.list.heading_user', :user => user.display_name + @description = t 'changeset.list.description_user', :user => user_link + elsif bbox + @title = t 'changeset.list.title_bbox', :bbox => bbox.to_s + @heading = t 'changeset.list.heading_bbox', :bbox => bbox.to_s + @description = t 'changeset.list.description_bbox', :bbox => bbox_link + else + @title = t 'changeset.list.title' + @heading = t 'changeset.list.heading' + @description = t 'changeset.list.description' + end - if user - user_link = render_to_string :partial => "user", :object => user - end + @page = (params[:page] || 1).to_i + @page_size = 20 - if user and bbox - @title = t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s - @heading = t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s - @description = t 'changeset.list.description_user_bbox', :user => user_link, :bbox => bbox_link - elsif user - @title = t 'changeset.list.title_user', :user => user.display_name - @heading = t 'changeset.list.heading_user', :user => user.display_name - @description = t 'changeset.list.description_user', :user => user_link - elsif bbox - @title = t 'changeset.list.title_bbox', :bbox => bbox.to_s - @heading = t 'changeset.list.heading_bbox', :bbox => bbox.to_s - @description = t 'changeset.list.description_bbox', :bbox => bbox_link - else - @title = t 'changeset.list.title' - @heading = t 'changeset.list.heading' - @description = t 'changeset.list.description' + @edits = Changeset.find(:all, + :include => [:user, :changeset_tags], + :conditions => conditions, + :order => "changesets.created_at DESC", + :offset => (@page - 1) * @page_size, + :limit => @page_size) end - - @page = (params[:page] || 1).to_i - @page_size = 20 - - @edits = Changeset.find(:all, - :include => [:user, :changeset_tags], - :conditions => conditions, - :order => "changesets.created_at DESC", - :offset => (@page - 1) * @page_size, - :limit => @page_size) end private