Merge branch 'master' into terms
authorTom Hughes <tom@compton.nu>
Sun, 9 May 2010 16:16:43 +0000 (17:16 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 9 May 2010 16:16:43 +0000 (17:16 +0100)
1  2 
app/controllers/user_controller.rb

index 8fdb89b227c628c78807a87535d42c5f961edb6e,42a50582e9831690dc66a6e21fb50e2c605e11d7..1bab42266e08bf3f47cb91db9afade9362c4cc81
@@@ -18,29 -18,11 +18,29 @@@ class UserController < ApplicationContr
  
    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])
  
@@@ -49,7 -31,6 +49,7 @@@
        @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 params[:user]
            @user.pass_crypt = params[:user][:pass_crypt]
            @user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
-           @user.status = "active"
+           @user.status = "active" if @user.status == "pending"
            @user.email_valid = true
  
            if @user.save