mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
2fb319bd96
10 changed files with 73 additions and 20 deletions
|
@ -51,11 +51,17 @@ class Domain < ActiveRecord::Base
|
||||||
before_create :generate_auth_info
|
before_create :generate_auth_info
|
||||||
before_create :set_validity_dates
|
before_create :set_validity_dates
|
||||||
before_create :attach_default_contacts
|
before_create :attach_default_contacts
|
||||||
after_save :manage_automatic_statuses
|
|
||||||
before_save :touch_always_version
|
before_save :touch_always_version
|
||||||
def touch_always_version
|
def touch_always_version
|
||||||
self.updated_at = Time.now
|
self.updated_at = Time.now
|
||||||
end
|
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 :name_dirty, domain_name: true, uniqueness: true
|
||||||
validates :period, numericality: { only_integer: true }
|
validates :period, numericality: { only_integer: true }
|
||||||
|
@ -295,6 +301,47 @@ class Domain < ActiveRecord::Base
|
||||||
log
|
log
|
||||||
end
|
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
|
class << self
|
||||||
def convert_period_to_time(period, unit)
|
def convert_period_to_time(period, unit)
|
||||||
return period.to_i.days if unit == 'd'
|
return period.to_i.days if unit == 'd'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Whois
|
module Whois
|
||||||
class PublicDomain < PublicServer
|
class Domain < Whois::Server
|
||||||
self.table_name = 'domains'
|
self.table_name = 'domains'
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,5 +0,0 @@
|
||||||
module Whois
|
|
||||||
class PrivateDomain < PrivateServer
|
|
||||||
self.table_name = 'domains'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
module Whois
|
|
||||||
class PrivateServer < ActiveRecord::Base
|
|
||||||
self.abstract_class = true
|
|
||||||
# establish_connection :"#{Rails.env}_private_whois"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
module Whois
|
|
||||||
class PublicServer < ActiveRecord::Base
|
|
||||||
self.abstract_class = true
|
|
||||||
# establish_connection :"#{Rails.env}_public_whois"
|
|
||||||
end
|
|
||||||
end
|
|
6
app/models/whois/server.rb
Normal file
6
app/models/whois/server.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module Whois
|
||||||
|
class Server < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
establish_connection :"whois_#{Rails.env}"
|
||||||
|
end
|
||||||
|
end
|
|
@ -39,6 +39,8 @@ module Registry
|
||||||
# Instead, the errors will propagate normally just like in other Active Record callbacks.
|
# Instead, the errors will propagate normally just like in other Active Record callbacks.
|
||||||
config.active_record.raise_in_transactional_callbacks = true
|
config.active_record.raise_in_transactional_callbacks = true
|
||||||
|
|
||||||
|
config.active_job.queue_adapter = :delayed_job
|
||||||
|
|
||||||
config.generators do |g|
|
config.generators do |g|
|
||||||
g.stylesheets false
|
g.stylesheets false
|
||||||
g.javascripts false
|
g.javascripts false
|
||||||
|
|
5
db/migrate/20150203074508_add_whois_body.rb
Normal file
5
db/migrate/20150203074508_add_whois_body.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddWhoisBody < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :domains, :whois_body, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150202084444) do
|
ActiveRecord::Schema.define(version: 20150203074508) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -199,6 +199,7 @@ ActiveRecord::Schema.define(version: 20150202084444) do
|
||||||
t.string "period_unit", limit: 1
|
t.string "period_unit", limit: 1
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
|
t.text "whois_body"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "epp_sessions", force: :cascade do |t|
|
create_table "epp_sessions", force: :cascade do |t|
|
||||||
|
|
|
@ -33,6 +33,11 @@ describe Domain do
|
||||||
it 'should not have any versions' do
|
it 'should not have any versions' do
|
||||||
@domain.versions.should == []
|
@domain.versions.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should not have whois_body' do
|
||||||
|
@domain.whois_body.should == nil
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
|
@ -51,6 +56,10 @@ describe Domain do
|
||||||
@domain.errors.full_messages.should match_array([])
|
@domain.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have whois_body' do
|
||||||
|
@domain.whois_body.present?.should == true
|
||||||
|
end
|
||||||
|
|
||||||
context 'with versioning' do
|
context 'with versioning' do
|
||||||
it 'should not have one version' do
|
it 'should not have one version' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue