Story#105997358 added more states which prohibit domain to be renewed + simplier days calculation

This commit is contained in:
Vladimir Krylov 2015-10-29 12:51:37 +02:00
parent 736aff0fc8
commit c7cd394214
2 changed files with 11 additions and 2 deletions

View file

@ -349,12 +349,16 @@ class Domain < ActiveRecord::Base
def renewable? def renewable?
if Setting.days_to_renew_domain_before_expire != 0 if Setting.days_to_renew_domain_before_expire != 0
if ((valid_to - Time.zone.now.beginning_of_day).to_i / 1.day) + 1 > Setting.days_to_renew_domain_before_expire # if you can renew domain at days_to_renew before domain expiration
if (valid_to.to_date - Date.today) + 1 > Setting.days_to_renew_domain_before_expire
return false return false
end end
end end
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE) return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_TRANSFER, DomainStatus::PENDING_DELETE,
DomainStatus::PENDING_UPDATE, 'pendingDeleteConfirmation')
true true
end end

View file

@ -0,0 +1,5 @@
class Array
def include_any? *args
(self & args).any?
end
end