]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Merge branch 'master' into terms
[rails.git] / app / controllers / user_controller.rb
index 2e25719524e0c46c5d0da968831981367ee955f3..43a6db790bc8e25375f15bf0ef57778b31d9dc0f 100644 (file)
@@ -22,10 +22,14 @@ class UserController < ApplicationController
     @title = t 'user.new.title'
     @user = User.new(params[:user])
 
-    country_code = params[:legale] || OSM.IPToCountry(request.remote_ip)
-    @text = OSM.legal_text_for_country(country_code)
+    @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale']
+    @text = OSM.legal_text_for_country(@legale)
 
-    if @user.invalid?
+    if request.xhr?
+      render :update do |page|
+        page.replace_html "contributorTerms", :partial => "terms"
+      end
+    elsif @user.invalid?
       render :action => 'new'
     end
   end
@@ -35,6 +39,8 @@ class UserController < ApplicationController
 
     if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"})
       render :action => 'new'
+    elsif params[:decline]
+      redirect_to t 'user.terms.declined'
     else
       @user = User.new(params[:user])