mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Merge branch 'story/105418634-generate-record' into staging
This commit is contained in:
commit
a325db2bb9
5 changed files with 65 additions and 50 deletions
|
@ -6,14 +6,6 @@ class WhoisRecord < ActiveRecord::Base
|
|||
validates :domain, :name, :body, :json, presence: true
|
||||
|
||||
before_validation :populate
|
||||
def populate
|
||||
return if domain_id.blank?
|
||||
self.json = generate_json
|
||||
self.body = generated_body
|
||||
self.name = json['name']
|
||||
self.registrar_id = domain.registrar_id # for faster registrar updates
|
||||
end
|
||||
|
||||
after_save :update_whois_server
|
||||
|
||||
class << self
|
||||
|
@ -30,6 +22,10 @@ class WhoisRecord < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def generated_json
|
||||
@generated_json ||= generate_json
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def generate_json
|
||||
|
@ -92,6 +88,8 @@ class WhoisRecord < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def generated_body
|
||||
self.json = generated_json if self.json.blank?
|
||||
|
||||
template = Rails.root.join("app/views/for_models/whois.erb".freeze)
|
||||
ERB.new(template.read, nil, "-").result.binding
|
||||
end
|
||||
|
@ -99,6 +97,14 @@ class WhoisRecord < ActiveRecord::Base
|
|||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
|
||||
def populate
|
||||
return if domain_id.blank?
|
||||
self.json = generated_json
|
||||
self.body = generated_body
|
||||
self.name = json['name']
|
||||
self.registrar_id = domain.registrar_id # for faster registrar updates
|
||||
end
|
||||
|
||||
def update_whois_server
|
||||
wd = Whois::Record.find_or_initialize_by(name: name)
|
||||
wd.body = body
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
||||
Domain:
|
||||
name: <%= json[:name] %>
|
||||
<%- for st in Array(json[:status]) -%>
|
||||
name: <%= json['name'] %>
|
||||
<%- for st in Array(json['status']) -%>
|
||||
status: <%= st %>
|
||||
<%- end -%>
|
||||
registered: <%= json[:registered].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
expire: <%= json[:expire].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
outzone: <%= json[:outzone].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
delete: <%= json[:delete].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
registered: <%= json['registered'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
expire: <%= json['expire'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
outzone: <%= json['outzone'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
delete: <%= json['delete'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
Registrant:
|
||||
name: <%= json[:registrant] %>
|
||||
name: <%= json['registrant'] %>
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= json[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- if json[:admin_contacts].present? -%>
|
||||
<%- if json['admin_contacts'].present? -%>
|
||||
Administrative contact
|
||||
<%- for contact in json[:admin_contacts] -%>
|
||||
name: <%= contact[:name] %>
|
||||
<%- for contact in json['admin_contacts'] -%>
|
||||
name: <%= contact['name'] %>
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= contact[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
<% if json[:tech_contacts].present? %>
|
||||
<% if json['tech_contacts'].present? %>
|
||||
Technical contact:
|
||||
<%- for contact in json[:admin_contacts] -%>
|
||||
name: <%= contact[:name] %>
|
||||
<%- for contact in json['admin_contacts'] -%>
|
||||
name: <%= contact['name'] %>
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= contact[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
Registrar:
|
||||
name: <%= json[:registrar] %>
|
||||
url: <%= json[:registrar_url] %>
|
||||
phone: <%= json[:registrar_phone] %>
|
||||
changed: <%= json[:registrar_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
name: <%= json['registrar'] %>
|
||||
url: <%= json['registrar_url'] %>
|
||||
phone: <%= json['registrar_phone'] %>
|
||||
changed: <%= json['registrar_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- if json[:nameservers].present? -%>
|
||||
<%- if json['nameservers'].present? -%>
|
||||
Name servers:
|
||||
<%- for server in json[:nameservers] -%>
|
||||
<%- for server in json['nameservers'] -%>
|
||||
nserver: <%= server %>
|
||||
<%- end -%>
|
||||
changed: <%= json[:nameservers_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json['nameservers_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- end -%>
|
||||
<%- if json[:dnssec_keys].present? -%>
|
||||
<%- if json['dnssec_keys'].present? -%>
|
||||
DNSSEC:
|
||||
<%- for key in json[:dnssec_keys] -%>
|
||||
<%- for key in json['dnssec_keys'] -%>
|
||||
dnskey: <%= key %>
|
||||
<%- end -%>
|
||||
changed: <%= json[:dnssec_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json['dnssec_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- end -%>
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
|
5
db/migrate/20151028183132_add_updated_at_to_dnskey.rb
Normal file
5
db/migrate/20151028183132_add_updated_at_to_dnskey.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddUpdatedAtToDnskey < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :dnskeys, :updated_at, :datetime
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150921111842) do
|
||||
ActiveRecord::Schema.define(version: 20151028183132) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -253,6 +253,7 @@ ActiveRecord::Schema.define(version: 20150921111842) do
|
|||
t.string "creator_str"
|
||||
t.string "updator_str"
|
||||
t.integer "legacy_domain_id"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "dnskeys", ["delegation_signer_id"], name: "index_dnskeys_on_delegation_signer_id", using: :btree
|
||||
|
|
|
@ -745,7 +745,8 @@ CREATE TABLE dnskeys (
|
|||
ds_digest character varying,
|
||||
creator_str character varying,
|
||||
updator_str character varying,
|
||||
legacy_domain_id integer
|
||||
legacy_domain_id integer,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
|
@ -5480,3 +5481,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150921110152');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150921111842');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20151028183132');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue