Commit f5ae9770c857be5586e15a2eb567eda33a32bc72
1 parent
28a318d6
ActionItem603: added some more treatment to user responses
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/branches/0.10.x@2381 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
59 additions
and
5 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -143,6 +143,18 @@ class AccountController < PublicController |
143 | 143 | def accept_terms |
144 | 144 | @enterprise = load_enterprise |
145 | 145 | @question = @enterprise.question |
146 | + | |
147 | + if @enterprise.enabled | |
148 | + render :action => 'already_activated' | |
149 | + return | |
150 | + end | |
151 | + | |
152 | + @question = @enterprise.question | |
153 | + if !@question || @enterprise.blocked? | |
154 | + render :action => 'blocked' | |
155 | + return | |
156 | + end | |
157 | + | |
146 | 158 | check_answer |
147 | 159 | @terms_of_enterprise_use = environment.terms_of_enterprise_use |
148 | 160 | end |
... | ... | @@ -150,6 +162,18 @@ class AccountController < PublicController |
150 | 162 | def activate_enterprise |
151 | 163 | @enterprise = load_enterprise |
152 | 164 | @question = @enterprise.question |
165 | + | |
166 | + if @enterprise.enabled | |
167 | + render :action => 'already_activated' | |
168 | + return | |
169 | + end | |
170 | + | |
171 | + @question = @enterprise.question | |
172 | + if !@question || @enterprise.blocked? | |
173 | + render :action => 'blocked' | |
174 | + return | |
175 | + end | |
176 | + | |
153 | 177 | return unless check_answer |
154 | 178 | return unless check_acceptance_of_terms |
155 | 179 | load_user | ... | ... |
app/models/environment.rb
... | ... | @@ -154,11 +154,11 @@ class Environment < ActiveRecord::Base |
154 | 154 | end |
155 | 155 | |
156 | 156 | def activation_blocked_text |
157 | - self.settings['activation_bocked_text'] | |
157 | + self.settings['activation_blocked_text'] | |
158 | 158 | end |
159 | 159 | |
160 | 160 | def activation_blocked_text= value |
161 | - self.settings['activation_bocked_text'] = value | |
161 | + self.settings['activation_blocked_text'] = value | |
162 | 162 | end |
163 | 163 | |
164 | 164 | ... | ... |
app/views/account/activation_question.rhtml
... | ... | @@ -2,8 +2,8 @@ |
2 | 2 | function check_valid_year(form) { |
3 | 3 | var answer = parseInt(form.answer.value); |
4 | 4 | var val = form.answer.value; |
5 | - if (!answer || (val.length != 4)) { | |
6 | - alert(<%= _('An year have 4 digits').inspect %>); | |
5 | + if (!answer || (val.length != 4) || val > <%= Time.now.year %> || val < 1900) { | |
6 | + alert(<%= (_('The year must be between %d and %d') % [1900, Time.now.year]).inspect %>); | |
7 | 7 | return false; |
8 | 8 | } else { |
9 | 9 | return true; | ... | ... |
app/views/account/blocked.rhtml
1 | -<%# FIXME: use environment blocked text %> | |
1 | +<div class='blocked-warning' > | |
2 | +<center><h1><%= _('This enterprise can\'t be activated by the system') %></h1></center> | |
3 | +<p><%= _('Unfortunately this enterprise can\'t be activated via the system.') %></p> | |
4 | +<p> | |
5 | +<% if @enterprise.blocked? %> | |
6 | + <%= _('There was a failed atempt of activation and the automated acivation was disabled for your security.') %> | |
7 | +<% else %> | |
8 | + <%= _('We don\'t have enough information about your enterprise to identify you.') %> | |
9 | +<% end %> | |
10 | +</p> | |
11 | + | |
2 | 12 | <% if @environment.activation_blocked_text.nil? %> |
3 | 13 | <%= _('Your enterprise has been blocked') %> |
4 | 14 | <% else %> |
5 | 15 | <%= @environment.activation_blocked_text %> |
6 | 16 | <% end %> |
17 | +</div> | ... | ... |
public/designs/themes/ecosol/stylesheets/controller_account.css
test/functional/account_controller_test.rb
... | ... | @@ -484,6 +484,20 @@ class AccountControllerTest < Test::Unit::TestCase |
484 | 484 | assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'enterprise_code', :value => '0123456789'} |
485 | 485 | end |
486 | 486 | |
487 | + should 'block who is blocked but directly arrive in the second step' do | |
488 | + ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) | |
489 | + ent.block | |
490 | + ent.save | |
491 | + | |
492 | + task = mock | |
493 | + task.expects(:enterprise).returns(ent).at_least_once | |
494 | + EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once | |
495 | + | |
496 | + get :accept_terms, :enterprise_code => '0123456789', :answer => 1998 | |
497 | + | |
498 | + assert_template 'blocked' | |
499 | + end | |
500 | + | |
487 | 501 | # end of enterprise activation tests |
488 | 502 | |
489 | 503 | should 'not be able to signup while inverse captcha field filled' do | ... | ... |