diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 0f1be4b..90b6612 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -143,6 +143,18 @@ class AccountController < PublicController def accept_terms @enterprise = load_enterprise @question = @enterprise.question + + if @enterprise.enabled + render :action => 'already_activated' + return + end + + @question = @enterprise.question + if !@question || @enterprise.blocked? + render :action => 'blocked' + return + end + check_answer @terms_of_enterprise_use = environment.terms_of_enterprise_use end @@ -150,6 +162,18 @@ class AccountController < PublicController def activate_enterprise @enterprise = load_enterprise @question = @enterprise.question + + if @enterprise.enabled + render :action => 'already_activated' + return + end + + @question = @enterprise.question + if !@question || @enterprise.blocked? + render :action => 'blocked' + return + end + return unless check_answer return unless check_acceptance_of_terms load_user diff --git a/app/models/environment.rb b/app/models/environment.rb index 15dd48f..4a527d6 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -154,11 +154,11 @@ class Environment < ActiveRecord::Base end def activation_blocked_text - self.settings['activation_bocked_text'] + self.settings['activation_blocked_text'] end def activation_blocked_text= value - self.settings['activation_bocked_text'] = value + self.settings['activation_blocked_text'] = value end diff --git a/app/views/account/activation_question.rhtml b/app/views/account/activation_question.rhtml index 1c7f73d..5c56f7d 100644 --- a/app/views/account/activation_question.rhtml +++ b/app/views/account/activation_question.rhtml @@ -2,8 +2,8 @@ function check_valid_year(form) { var answer = parseInt(form.answer.value); var val = form.answer.value; - if (!answer || (val.length != 4)) { - alert(<%= _('An year have 4 digits').inspect %>); + if (!answer || (val.length != 4) || val > <%= Time.now.year %> || val < 1900) { + alert(<%= (_('The year must be between %d and %d') % [1900, Time.now.year]).inspect %>); return false; } else { return true; diff --git a/app/views/account/blocked.rhtml b/app/views/account/blocked.rhtml index 73e3624..918f640 100644 --- a/app/views/account/blocked.rhtml +++ b/app/views/account/blocked.rhtml @@ -1,6 +1,17 @@ -<%# FIXME: use environment blocked text %> +
+

<%= _('This enterprise can\'t be activated by the system') %>

+

<%= _('Unfortunately this enterprise can\'t be activated via the system.') %>

+

+<% if @enterprise.blocked? %> + <%= _('There was a failed atempt of activation and the automated acivation was disabled for your security.') %> +<% else %> + <%= _('We don\'t have enough information about your enterprise to identify you.') %> +<% end %> +

+ <% if @environment.activation_blocked_text.nil? %> <%= _('Your enterprise has been blocked') %> <% else %> <%= @environment.activation_blocked_text %> <% end %> +
diff --git a/public/designs/themes/ecosol/stylesheets/controller_account.css b/public/designs/themes/ecosol/stylesheets/controller_account.css index c1c19df..44752e8 100644 --- a/public/designs/themes/ecosol/stylesheets/controller_account.css +++ b/public/designs/themes/ecosol/stylesheets/controller_account.css @@ -23,3 +23,8 @@ color: #3465A4; } +.blocked-warning { + border: 2px solid #3465A4; + padding: 10px 5px 10px 20px; + background: #E86F67; +} diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 6600789..e40e12d 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -484,6 +484,20 @@ class AccountControllerTest < Test::Unit::TestCase assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'enterprise_code', :value => '0123456789'} end + should 'block who is blocked but directly arrive in the second step' do + ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_ent', :foundation_year => 1998, :enabled => false) + ent.block + ent.save + + task = mock + task.expects(:enterprise).returns(ent).at_least_once + EnterpriseActivation.expects(:find_by_code).with('0123456789').returns(task).at_least_once + + get :accept_terms, :enterprise_code => '0123456789', :answer => 1998 + + assert_template 'blocked' + end + # end of enterprise activation tests should 'not be able to signup while inverse captcha field filled' do -- libgit2 0.21.2