mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
11031910-callbacks_for_whois_server
This commit is contained in:
parent
2d35556f2b
commit
a440169eaf
3 changed files with 42 additions and 1 deletions
|
@ -24,7 +24,7 @@ class Admin::ReservedDomainsController < AdminController
|
||||||
ReservedDomain.transaction do
|
ReservedDomain.transaction do
|
||||||
# removing old ones
|
# removing old ones
|
||||||
existing = ReservedDomain.any_of_domains(names.keys).pluck(:id)
|
existing = ReservedDomain.any_of_domains(names.keys).pluck(:id)
|
||||||
ReservedDomain.where.not(id: existing).delete_all
|
ReservedDomain.where.not(id: existing).destroy_all
|
||||||
|
|
||||||
#updating and adding
|
#updating and adding
|
||||||
names.each do |name, psw|
|
names.each do |name, psw|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
class ReservedDomain < ActiveRecord::Base
|
class ReservedDomain < ActiveRecord::Base
|
||||||
include Versions # version/reserved_domain_version.rb
|
include Versions # version/reserved_domain_version.rb
|
||||||
before_save :fill_empty_passwords
|
before_save :fill_empty_passwords
|
||||||
|
before_save :generate_data
|
||||||
|
before_destroy :remove_data
|
||||||
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def pw_for(domain_name)
|
def pw_for(domain_name)
|
||||||
|
@ -25,4 +28,34 @@ class ReservedDomain < ActiveRecord::Base
|
||||||
def name= val
|
def name= val
|
||||||
super SimpleIDN.to_unicode(val)
|
super SimpleIDN.to_unicode(val)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_data
|
||||||
|
@json = generate_json
|
||||||
|
@body = generate_body
|
||||||
|
update_whois_server
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_whois_server
|
||||||
|
wr = Whois::Record.find_or_initialize_by(name: name)
|
||||||
|
wr.body = @body
|
||||||
|
wr.json = @json
|
||||||
|
wr.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_body
|
||||||
|
template = Rails.root.join("app/views/for_models/whois_other.erb".freeze)
|
||||||
|
ERB.new(template.read, nil, "-").result(binding)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_json
|
||||||
|
h = HashWithIndifferentAccess.new
|
||||||
|
h[:name] = self.name
|
||||||
|
h[:status] = 'Reserved'
|
||||||
|
h
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_data
|
||||||
|
Whois::Record.where(name: name).delete_all
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
8
app/views/for_models/whois_other.erb
Normal file
8
app/views/for_models/whois_other.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
|
||||||
|
Domain:
|
||||||
|
name: <%= @json['name'] %>
|
||||||
|
status: <%= @json['status'] %>
|
||||||
|
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
More information at http://internet.ee
|
Loading…
Add table
Add a link
Reference in a new issue