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 %> +
<%= _('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 %> +