mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Handle OK status automatically
This commit is contained in:
parent
8892a25947
commit
77510cc3fa
5 changed files with 19 additions and 10 deletions
|
@ -36,6 +36,7 @@ class Domain < ActiveRecord::Base
|
|||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
after_create :attach_default_contacts
|
||||
after_save :manage_automatic_statuses
|
||||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
validates :period, numericality: { only_integer: true }
|
||||
|
@ -201,6 +202,14 @@ class Domain < ActiveRecord::Base
|
|||
domain_contacts.reject(&:marked_for_destruction?).select { |x| x.contact_type == DomainContact::ADMIN }.count
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
if domain_statuses.empty? && valid?
|
||||
domain_statuses.create(value: DomainStatus::OK)
|
||||
else
|
||||
domain_statuses.find_by(value: DomainStatus::OK).try(:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def convert_period_to_time(period, unit)
|
||||
return period.to_i.days if unit == 'd'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue