]> 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 83c414ef2ccb1fecabd2b757f92f2ad52669b868..2e25719524e0c46c5d0da968831981367ee955f3 100644 (file)
@@ -18,6 +18,18 @@ class UserController < ApplicationController
 
   cache_sweeper :user_sweeper, :only => [:account, :hide, :unhide, :delete]
 
 
   cache_sweeper :user_sweeper, :only => [:account, :hide, :unhide, :delete]
 
+  def terms
+    @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)
+
+    if @user.invalid?
+      render :action => 'new'
+    end
+  end
+
   def save
     @title = t 'user.new.title'
 
   def save
     @title = t 'user.new.title'
 
@@ -31,6 +43,7 @@ class UserController < ApplicationController
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
       @user.languages = request.user_preferred_languages
       @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'
 
       if @user.save
         flash[:notice] = t 'user.new.flash create success message'
@@ -209,8 +222,6 @@ class UserController < ApplicationController
         @user = token.user
         @user.active = true
         @user.email_valid = true
         @user = token.user
         @user.active = true
         @user.email_valid = true
-        @user.terms_agreed = Time.now.getutc
-        @user.consider_pd = true if params[:consider_pd]
         @user.save!
         referer = token.referer
         token.destroy
         @user.save!
         referer = token.referer
         token.destroy