X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/30c47f4ac491f5cfa39e281dbb8b9a0d1916eaca..bcf8574dde38ab0473713dbea24ec49016a63853:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 430e56cb0..5b6222a98 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,9 +4,9 @@ class UserController < ApplicationController before_filter :authorize, :only => [:api_details, :api_gpx_files] before_filter :authorize_web, :except => [:api_details, :api_gpx_files] before_filter :set_locale, :except => [:api_details, :api_gpx_files] - before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image] + before_filter :require_user, :only => [:account, :go_public, :make_friend, :remove_friend] before_filter :check_database_readable, :except => [:api_details, :api_gpx_files] - before_filter :check_database_writable, :only => [:login, :new, :set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image] + before_filter :check_database_writable, :only => [:login, :new, :account, :go_public, :make_friend, :remove_friend] before_filter :check_api_readable, :only => [:api_details, :api_gpx_files] before_filter :require_allow_read_prefs, :only => [:api_details] before_filter :require_allow_read_gpx, :only => [:api_gpx_files] @@ -57,6 +57,12 @@ class UserController < ApplicationController @user.description = params[:user][:description] @user.languages = params[:user][:languages].split(",") + + case params[:image_action] + when "new" then @user.image = params[:user][:image] + when "delete" then @user.image = nil + end + @user.home_lat = params[:user][:home_lat] @user.home_lon = params[:user][:home_lon] @@ -85,17 +91,6 @@ class UserController < ApplicationController end end - def set_home - if params[:user][:home_lat] and params[:user][:home_lon] - @user.home_lat = params[:user][:home_lat].to_f - @user.home_lon = params[:user][:home_lon].to_f - if @user.save - flash[:notice] = t 'user.set_home.flash success' - redirect_to :controller => 'user', :action => 'account' - end - end - end - def go_public @user.data_public = true @user.save @@ -253,18 +248,6 @@ class UserController < ApplicationController end end - def upload_image - @user.image = params[:user][:image] - @user.save! - redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name - end - - def delete_image - @user.image = nil - @user.save! - redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name - end - def api_gpx_files doc = OSM::API.new.get_xml_doc @user.traces.each do |trace| @@ -304,7 +287,11 @@ class UserController < ApplicationController flash[:warning] = t 'user.make_friend.already_a_friend', :name => name end - redirect_to :controller => 'user', :action => 'view' + if params[:referer] + redirect_to params[:referer] + else + redirect_to :controller => 'user', :action => 'view' + end end end @@ -319,7 +306,11 @@ class UserController < ApplicationController flash[:error] = t 'user.remove_friend.not_a_friend', :name => friend.display_name end - redirect_to :controller => 'user', :action => 'view' + if params[:referer] + redirect_to params[:referer] + else + redirect_to :controller => 'user', :action => 'view' + end end end