Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-02-03 11:20:00 +02:00
commit 2fb319bd96
10 changed files with 73 additions and 20 deletions

View file

@ -51,11 +51,17 @@ class Domain < ActiveRecord::Base
before_create :generate_auth_info
before_create :set_validity_dates
before_create :attach_default_contacts
after_save :manage_automatic_statuses
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.now
end
before_save :update_whois_body
after_save :manage_automatic_statuses
after_save :delay_whois_server_update
def delay_whois_server_update
return if whois_body.blank?
delay.whois_server_update(name, whois_body)
end
validates :name_dirty, domain_name: true, uniqueness: true
validates :period, numericality: { only_integer: true }
@ -295,6 +301,47 @@ class Domain < ActiveRecord::Base
log
end
def update_whois_body
self.whois_body = <<-EOS
This Whois Server contains information on
Estonian Top Level Domain ee TLD
domain: #{name}
registrar: #{registrar}
status:
registered:
changed: #{updated_at.to_s(:db)}
expire:
outzone:
delete:
contact
name:
e-mail:
registrar:
created:
contact:
nsset:
nserver:
registrar:
org:
url:
phone:
address:
created:
changed:
EOS
end
def whois_server_update(name = name, whois_body = whois_body)
wd = Whois::Domain.find_or_initialize_by(name: name)
wd.whois_body = whois_body
wd.save
end
class << self
def convert_period_to_time(period, unit)
return period.to_i.days if unit == 'd'

View file

@ -1,5 +1,5 @@
module Whois
class PublicDomain < PublicServer
class Domain < Whois::Server
self.table_name = 'domains'
end
end

View file

@ -1,5 +0,0 @@
module Whois
class PrivateDomain < PrivateServer
self.table_name = 'domains'
end
end

View file

@ -1,6 +0,0 @@
module Whois
class PrivateServer < ActiveRecord::Base
self.abstract_class = true
# establish_connection :"#{Rails.env}_private_whois"
end
end

View file

@ -1,6 +0,0 @@
module Whois
class PublicServer < ActiveRecord::Base
self.abstract_class = true
# establish_connection :"#{Rails.env}_public_whois"
end
end

View file

@ -0,0 +1,6 @@
module Whois
class Server < ActiveRecord::Base
self.abstract_class = true
establish_connection :"whois_#{Rails.env}"
end
end