mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 00:12:03 +02:00
Refactor validity dates to model
This commit is contained in:
parent
4c4edd3747
commit
80440d741b
5 changed files with 22 additions and 14 deletions
|
@ -27,6 +27,7 @@ class Domain < ActiveRecord::Base
|
|||
delegate :name, to: :registrar, prefix: true
|
||||
|
||||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
after_create :attach_default_contacts
|
||||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
|
@ -112,6 +113,12 @@ class Domain < ActiveRecord::Base
|
|||
admin_contacts << owner_contact if admin_contacts_count.zero? && owner_contact.citizen?
|
||||
end
|
||||
|
||||
def set_validity_dates
|
||||
self.registered_at = Time.zone.now
|
||||
self.valid_from = Date.today
|
||||
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||
end
|
||||
|
||||
def tech_contacts_count
|
||||
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }.count
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue