]> 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 42a50582e9831690dc66a6e21fb50e2c605e11d7..1bab42266e08bf3f47cb91db9afade9362c4cc81 100644 (file)
@@ -18,11 +18,29 @@ class UserController < ApplicationController
 
   cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete]
 
+  def terms
+    @title = t 'user.new.title'
+    @user = User.new(params[:user])
+
+    @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale']
+    @text = OSM.legal_text_for_country(@legale)
+
+    if request.xhr?
+      render :update do |page|
+        page.replace_html "contributorTerms", :partial => "terms"
+      end
+    elsif @user.invalid?
+      render :action => 'new'
+    end
+  end
+
   def save
     @title = t 'user.new.title'
 
     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])
 
@@ -31,6 +49,7 @@ class UserController < ApplicationController
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
       @user.languages = request.user_preferred_languages
+      @user.terms_agreed = Time.now.getutc
 
       if @user.save
         flash[:notice] = t 'user.new.flash create success message'