mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Set validity, outzone, delete dates on domain creation #2622
This commit is contained in:
parent
ffb1ab6521
commit
6546f51acf
3 changed files with 35 additions and 0 deletions
|
@ -152,6 +152,12 @@ class Domain < ActiveRecord::Base
|
|||
x.domain_statuses.create(value: DomainStatus::EXPIRED) if x.expirable?
|
||||
end
|
||||
end
|
||||
|
||||
def start_redemption_grace_period
|
||||
Domain.where('outzone_at <= ?', Time.zone.now).each do |x|
|
||||
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD) if x.server_holdable?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def name=(value)
|
||||
|
@ -189,6 +195,13 @@ class Domain < ActiveRecord::Base
|
|||
domain_statuses.where(value: DomainStatus::EXPIRED).empty?
|
||||
end
|
||||
|
||||
def server_holdable?
|
||||
return false if outzone_at > Time.zone.now
|
||||
return false if domain_statuses.where(value: DomainStatus::SERVER_HOLD).any?
|
||||
return false if domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).any?
|
||||
true
|
||||
end
|
||||
|
||||
def pending_update?
|
||||
(domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::PENDING_UPDATE}
|
||||
|
@ -329,6 +342,8 @@ class Domain < ActiveRecord::Base
|
|||
self.registered_at = Time.zone.now
|
||||
self.valid_from = Time.zone.now.to_date
|
||||
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||
self.outzone_at = self.valid_to + Setting.expire_warning_period.days
|
||||
self.delete_at = self.outzone_at + Setting.redemption_grace_period.days
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue