Allow existing users to voluntarily sign up for the contributor terms

Based on a patch from Frederik Ramm this change allows users to make a
voluntary decision to sign up for the new contributor terms.
This commit is contained in:
Tom Hughes 2010-08-10 18:08:11 +01:00
parent 2adcfc1a72
commit a99b516962
4 changed files with 63 additions and 13 deletions

View file

@ -19,9 +19,6 @@ class UserController < ApplicationController
cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => STATUS == :database_offline
def terms
@title = t 'user.new.title'
@user = User.new(params[:user])
@legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || DEFAULT_LEGALE
@text = OSM.legal_text_for_country(@legale)
@ -29,8 +26,19 @@ class UserController < ApplicationController
render :update do |page|
page.replace_html "contributorTerms", :partial => "terms"
end
elsif @user.invalid?
render :action => 'new'
else
@title = t 'user.terms.title'
@user = User.new(params[:user]) if params[:user]
if @user
if @user.invalid?
render :action => :new
elsif @user.terms_agreed?
redirect_to :action => :account, :display_name => @user.display_name
end
else
redirect_to :action => :login, :referer => request.request_uri
end
end
end
@ -41,6 +49,16 @@ class UserController < ApplicationController
render :action => 'new'
elsif params[:decline]
redirect_to t('user.terms.declined')
elsif @user
if !@user.terms_agreed?
@user.consider_pd = params[:user][:consider_pd]
@user.terms_agreed = Time.now.getutc
if @user.save
flash[:notice] = t 'user.new.terms accepted'
end
end
redirect_to :action => :account, :display_name => @user.display_name
else
@user = User.new(params[:user])

View file

@ -38,6 +38,24 @@
</td>
</tr>
<tr>
<td class="fieldName" valign="top"><%= t 'user.account.contributor terms.heading' %></td>
<td>
<% if @user.terms_agreed? %>
<%= t 'user.account.contributor terms.agreed' %>
<span class="minorNote">(<a href="<%= t 'user.account.contributor terms.link' %>" target="_new"><%= t 'user.account.contributor terms.link text' %></a>)</span>
<br />
<% if @user.consider_pd? %>
<%= t 'user.account.contributor terms.agreed_with_pd' %>
<% end %>
<% else %>
<%= t 'user.account.contributor terms.not yet agreed' %> <br />
<%= link_to t('user.account.contributor terms.review link text'), :controller => 'user', :action => 'terms' %>
<% end %>
</td>
</tr>
<tr>
<td class="fieldName" valign="top"><%= t 'user.account.profile description' %></td>
<td><%= f.text_area :description, :rows => '5', :cols => '60' %></td>

View file

@ -1,6 +1,6 @@
<h1><%= t 'user.terms.heading' %></h1>
<p><%= t 'user.terms.press accept button' %></p>
<p><%= t 'user.terms.read and accept' %></p>
<!-- legale is <%= @legale %> -->
<% form_tag :action => 'terms' do %>
@ -33,13 +33,17 @@
</p>
<p>
<%= hidden_field_tag('referer', h(params[:referer])) unless params[:referer].nil? %>
<%= hidden_field('user', 'email') %>
<%= hidden_field('user', 'email_confirmation') %>
<%= hidden_field('user', 'display_name') %>
<%= hidden_field('user', 'pass_crypt') %>
<%= hidden_field('user', 'pass_crypt_confirmation') %>
<% if params[:user] %>
<%= hidden_field('user', 'email') %>
<%= hidden_field('user', 'email_confirmation') %>
<%= hidden_field('user', 'display_name') %>
<%= hidden_field('user', 'pass_crypt') %>
<%= hidden_field('user', 'pass_crypt_confirmation') %>
<% end %>
<div id="buttons">
<%= submit_tag(t('user.terms.decline'), :name => "decline", :id => "decline") %>
<% if params[:user] %>
<%= submit_tag(t('user.terms.decline'), :name => "decline", :id => "decline") %>
<% end %>
<%= submit_tag(t('user.terms.agree'), :name => "agree", :id => "agree") %>
</div>
</p>